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

Hii i have a dataset like this

idreasfreq count
1317
1623
1756
1933
11024
2364
2623
2734
2864
21043

 and the output i want is can anyone help me how to solve this ?

reasid=1id=2
31764
62323
75634
83364
1024

43

 thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
proc sort data=have out=_have;
by reas;
run;

proc transpose data=_have out=want prefix=ID ;
by reas;
id id;
var freqcount;
run;

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20
proc sort data=have out=_have;
by reas;
run;

proc transpose data=_have out=want prefix=ID ;
by reas;
id id;
var freqcount;
run;
Aayushi_17
Quartz | Level 8
thank you all
ShiroAmada
Lapis Lazuli | Level 10

You can try data step or using sql


/* data step */
proc sort data=have;
  by reas;
run;

data want;
  length
  reas id_1 id_2 8;
  merge 
  have(where=(id=1) rename=(freqcount=id_1) in=a)
  have(where=(id=2) rename=(freqcount=id_2) in=b);
  by reas;
  drop id;
run;

/* PROC SQL */
proc sql;
  create table want3 as
  select 
  coalesce(a.reas,b.reas) as reas,
  a.freqcount as id_1,
  b.freqcount as Id_2
  from have(where=(id=1)) a full join 
  have(where=(id=2)) b 
  on a.reas=b.reas;
quit;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 673 views
  • 3 likes
  • 4 in conversation