Transposing Health and Retirement Study variables into long format on SAS

26 Views Asked by At

I have the following variables (all numberic) that I want to transpose into long format based on the ID variable HHIDPN

My ultimate goal is a linear mixed model analysis, but can't quite get this in the correct long format to create a time variable. the model will be r7cogtot=SSRI, r8cogtot=SSRI, etc. wherer7cogtot=cognition in 2004, r8cogtot= cognition in 2006, etc up until r12cogtot=2014.

S

SRI TCA STATIN IBUPROFEN ACETAMINOPHEN
r7cogtot r8cogtot r9cogtot r10cogtot r11cogtot r12cogtot 
r7agey_e r7conds r8conds r9conds r10conds r11conds r12conds  
r7cesd r8cesd r9cesd r10cesd r11cesd r12cesd 
h7icap h8icap h9icap h10icap h11icap h12icap 
insurance2 insurance4 insurance6 insurance8 insurance10
depression2 depression4 depression6 depression8 depression10
cog_change2 cog_change4 cog_change6 cog_change8 cog_change10 
gender race education

How exactly do I do this?

I have something like:

proc transpose data=time out=long_time;
by HHIDPN;
***not sure how to code the rest of the variables here;
run;

I am less worried about the rename and drop until I figure out how to keep each of those variables for the ID. I think I am just overthinking, but appreciate any help

I can't figure out the correct statement for my non ID variables

0

There are 0 best solutions below