Hi All,
I have a dataset below that I would like to transpose from wide to long format. I've always struggled with getting proc transpose to do what I envision but thinking that proc transpose can't handle this request. I have many other measurements and time periods so hopefully there is some method out there that can handle more than what I am presenting here in the data.
data have;
input id approach diet time1 measure1_1 measure2_1 $ time2 measure1_2 measure2_2 $ time3 measure1_3 measure2_3 $;
cards;
1 1 1 10 5 water 85 10 water 100 103 water
2 2 2 12 5 protein 92 11 water 102 103 water
;
run;
data want;
input id approach diet time measure1 measure2 $;
cards;
1 1 1 10 5 water
1 1 1 85 10 water
1 1 1 100 103 water
2 2 2 12 5 protein
2 2 2 92 11 water
2 2 2 102 103 water
;
run;
The %UNTRANSOPSE macro does exactly what you want.
https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf
The command shown on page 3 is analogous to your problem and ought to work.
The %UNTRANSOPSE macro does exactly what you want.
https://support.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2018/2419-2018.pdf
The command shown on page 3 is analogous to your problem and ought to work.
Works well, thanks for sharing!
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.