Combining Multiple lines into one line with Rename Variables

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

bnier
Posts: 1
Joined: Fri Jul 14, 2017 6:20 pm

Combining Multiple lines into one line with Rename Variables

Postby bnier » Fri Jul 14, 2017 6:50 pm

My database is structured in the following way. Each participant is on multiple lines based on time point.

Participant ID Visit var1 var2 var3
1 0 2 3 3
1 1 1 3 4
1 2 3 4 2
2 0 1 2 1
2 1 1 4 2
2 2 1 1 3

I am trying to rename the variables based on time point to make each participant one line, like so:
Participant ID var1.0 var2.0 var3.0 var1.1 var2.1 var3.1 var1.2 var2.2 var3.2
1 2 3 3 1 3 4 3 4 2
2 1 2 1 1 4 2 1 1 3

I'm currently trying to achieve this in a DO IF command:
DO IF visit=0.
RENAME VARIABLE var1=var1.0 var2=var2.0 var3=var3.0.
ELSE IF visit=1.
RENAME VARIABLE var1=var1.1 var2=var2.1 var3=var3.1.
ELSE IF visit=2.
RENAME VARIABLE var1=var1.2 var2=var2.2 var3=var3.2.

Am I thinking about this the right way? Any insight regarding how I could do this?

Thanks,
Brent

Who is online

Users browsing this forum: No registered users and 1 guest

cron