BookmarkSubscribeRSS Feed
ssas
Calcite | Level 5
Hi I am struck at this bit, could anyone guide me to how I can sortout
I have data like this
pc0809 v0809 p0910 v0910 p1011 v1011
a1 5 a4 23 a1 12
a7 45 a5 21 b1 32
a3 36 c4 41 a3 52
b1 28 a3 35 d2 20
a4 52 d2 62 y4 43
a5 32 e1 21 gg2 21

p members and their respective values in v

required output :
v20089 v0910 v1011
a1 5 - 12
a7 45 - -
a3 36 35 52
a4 52 23 -
b1 28 - 32
d2 - 62 20
e1 - 21 -

I have done
1. sort the data on P's
2. Proc tabulte
I am getting error values..
If anyone can guide me

Thanks in advance Message was edited by: ssas
1 REPLY 1
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Ssas,

This could be a possible solution to our problem:
[pre]
data a;
input p1 $ 1-2 v1 4-5 p2 $ 7-8 v2 10-11 p3 $ 13-14 v3 16-17;
datalines;
a1 5 a4 23 a1 12
a7 45 a5 21 b1 32
a3 36 c4 41 a3 52
b1 28 a3 35 d2 20
a4 52 d2 62 y4 43
a5 32 e1 21 g2 21
;
run;
data b;
set a(in=a1 keep=p1 v1 rename=(p1=p v1=v))
a(in=a2 keep=p2 v2 rename=(p2=p v2=v))
a(in=a3 keep=p3 v3 rename=(p3=p v3=v));
if a1 then var=1;
if a2 then var=2;
if a3 then var=3;
run;
proc sort data=b;
by p;
run;
proc transpose data=b out=r prefix=v;
var v;
id var;
by p;
run;
[/pre]
Sincerely,
SPR

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 974 views
  • 0 likes
  • 2 in conversation