Help using Base SAS procedures

Request for guideance

Reply
Contributor
Posts: 43

Request for guideance

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
Super Contributor
Super Contributor
Posts: 365

Re: Request for guideance

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
Ask a Question
Discussion stats
  • 1 reply
  • 119 views
  • 0 likes
  • 2 in conversation