BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PeterBr
Obsidian | Level 7

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;
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
PeterBr
Obsidian | Level 7

Works well, thanks for sharing!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 613 views
  • 0 likes
  • 2 in conversation