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