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

My data is currently in this format in SAS:

 

Current Output:

Month      Variable    Value

200501    variable1    0.01

200502    variable1    0.05

....

...

201812   variable1     0.05

200501    variable2    -0.05

200502    variable2    1.0

...

201812   variable2     1.5

 

How do I change it so it's in this format?

 

Desired Output

 

Month     Variable1 Variable2

200501    0.01         -0.05

200502    0.05           1.0

...

...

201812    0.05           1.5

 

I thought of using the transpose procedure, but that will likely not give me what I want.

 

Thanks.

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Good catch to spot the missing secondary sort to get the order right

by month variable;

🙂  That's attention to detail indeed 

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20
data have;
input (Month      Variable ) ($10. :)   Value;
cards;
200501    variable1    0.01
200502    variable1    0.05
201812   variable1     0.05
200501    variable2    -0.05
200502    variable2    1.0
201812   variable2     1.5
;

proc sort data=have;
by month;
run;
proc transpose data=have out=want(drop=_name_);
by month;
var value;
id variable;
run;
PaigeMiller
Diamond | Level 26
/* UNTESTED CODE */

proc sort data=have;
	by month variable;
run;
proc transpose data=have out=want(drop=_name_);
   by month;
   id variable;
run;
--
Paige Miller
novinosrin
Tourmaline | Level 20

Good catch to spot the missing secondary sort to get the order right

by month variable;

🙂  That's attention to detail indeed 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 822 views
  • 2 likes
  • 3 in conversation