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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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