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

hi,

 

Having some issue populating a summary table by date. Specifically, I would like each value under variable STATUS to appear horizontally. Is this possible with PROC FREQ?

 

Example data:

 

Data table1;

FORMAT DATE $12.  STATUS $2.;

Input DATE  STATUS ;

Datalines;

01MAR2017 DU

01MAR2017 DU

01MAR2017 DU

01MAR2017 FI

01MAR2017 FI

01MAR2017 TU

01MAR2017 TU

01MAR2017 Z1

01MAR2017 Z1

02MAR2017 DU

02MAR2017 FI

02MAR2017 TU

02MAR2017 Z1

Run;

 

Would like output table to look like this:

 

DATE               DU                      FI                       TU             ZI

01MAR2017      3                         2                        2                2     

02MAR2017      1                         1                        1                1

 

Proc Freq code

 

proc FREQ data=table1 NOPRINT;
TABLES Date * Status  /norow nocol NOPERCENT OUT=table2; 
RUN; 

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

OK, I think I get what you are asking for now.  Continue, adding to your program after the PROC FREQ:

 

proc transpose data=table2 out=want;

var count;

id status;

by date;

run;

 

You might need to drop _NAME_ from the result, but the pieces should now align the way you are asking.

View solution in original post

7 REPLIES 7
Astounding
PROC Star

How is this basic table different from what you desire?

 

tables date * status;

brulard
Pyrite | Level 9

thanks, tried that but the column is still listed "STATUS" with each value listed below, by date

Reeza
Super User

Post your code.

brulard
Pyrite | Level 9

i have ... 

proc FREQ data=table1 NOPRINT;
TABLES Date * Status  /norow nocol NOPERCENT OUT=table2; 
RUN; 

Thanks 

Astounding
PROC Star

OK, I think I get what you are asking for now.  Continue, adding to your program after the PROC FREQ:

 

proc transpose data=table2 out=want;

var count;

id status;

by date;

run;

 

You might need to drop _NAME_ from the result, but the pieces should now align the way you are asking.

brulard
Pyrite | Level 9
awesome, thanks!
Reeza
Super User
Yes it's possible.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 7 replies
  • 2884 views
  • 3 likes
  • 3 in conversation