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

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1033 views
  • 0 likes
  • 2 in conversation