Computing variable with data i long form

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

eirikp
Posts: 2
Joined: Tue Mar 08, 2016 9:46 am

Computing variable with data i long form

Postby eirikp » Tue Mar 08, 2016 10:11 am

I have the following dataset structure, in a format which in SPSS lingo is called "long form":

subject id measurement id measurement value 1 etc.
1 1 0.1
1 2 0.5
1 3 0.5
2 1 0.3
2 2 0.2
2 3 0.3
3 1 0.6
3 2 0.3
3 3 0.4
etc.

I want to calculate a new variable which holds the value from measurement id=1 for all measurement ids for each subject id. I.e.:


subject id measurement id measurement value 1 new variable etc.
1 1 0.1 0.1
1 2 0.5 0.1
1 3 0.5 0.1
2 1 0.3 0.3
2 2 0.2 0.3
2 3 0.3 0.3
3 1 0.6 0.6
3 2 0.3 0.6
3 3 0.4 0.6
etc.

Any suggestions for code that can do this? I use SPSS Version 21.
GerineL
Moderator
Posts: 1477
Joined: Tue Jun 10, 2008 4:50 pm

Re: Computing variable with data i long form

Postby GerineL » Tue Mar 08, 2016 10:23 am

use aggregate - first function with break on ID.

Also, if you just want to transform your dataset, there is also the restructure function.
eirikp
Posts: 2
Joined: Tue Mar 08, 2016 9:46 am

Re: Computing variable with data i long form

Postby eirikp » Tue Mar 08, 2016 1:56 pm

Thank you so much!

Who is online

Users browsing this forum: No registered users and 1 guest

cron