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

Hi there,

I am trying to crreate a table having summary of report submitted in each month and experiencing some problem. Can somebody help me to overcome the obstacle. Sample of the table,  I am havcing as well as I am expecting are given below. Thank you in advance for your kind reply. 

data have;
input id mon $ count ;
cards;
101 jan 10
101 feb 20
101 mar 25
101 jun 20
102 jan 10
102 feb 20
102 Apr 25
102 may 20
103 Apr 10
103 feb 20
103 mar 25
103 may 20
103 jul 25
;
run;


data want;
input id jan feb mar apr may jun jul;
cards;
101 10 20 25 . . 20 .
102 10 20 . 25 20 . .
103 . 20 25 10 20 . 25
;
run;

Regards,

 

Swain
1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Often, a good tool to transpose data is PROC TRANSPOSE:

 

proc transpose data=have out=want (drop=_name_);

var count;

id mon;

by id;

run;

 

The documentation describes the purpose of each of the statements.

 

View solution in original post

4 REPLIES 4
Astounding
PROC Star

Often, a good tool to transpose data is PROC TRANSPOSE:

 

proc transpose data=have out=want (drop=_name_);

var count;

id mon;

by id;

run;

 

The documentation describes the purpose of each of the statements.

 

DeepakSwain
Pyrite | Level 9

Thank you for your valuable reply.

Regards,

Swain
ballardw
Super User

Of course if you are generating a report then perhaps a report procedure is in order.

 

proc report data=have nowd;
   column id (mon, count);
   define id/group;
   define mon/across;
   define count/analysis ;
run;
DeepakSwain
Pyrite | Level 9

Thank you for providing an alternative approach. Appreciated. 

 

Regards,

Swain

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 854 views
  • 3 likes
  • 3 in conversation