PROC FREQ syntax issue

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 98
Accepted Solution

PROC FREQ syntax issue

[ Edited ]

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

 


Accepted Solutions
Solution
‎08-31-2017 12:30 PM
Super User
Posts: 5,598

Re: PROC FREQ syntax issue

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


All Replies
Super User
Posts: 5,598

Re: PROC FREQ syntax issue

How is this basic table different from what you desire?

 

tables date * status;

Frequent Contributor
Posts: 98

Re: PROC FREQ syntax issue

Posted in reply to Astounding

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

Super User
Posts: 20,203

Re: PROC FREQ syntax issue

Post your code.

Frequent Contributor
Posts: 98

Re: PROC FREQ syntax issue

i have ... 

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

Thanks 

Solution
‎08-31-2017 12:30 PM
Super User
Posts: 5,598

Re: PROC FREQ syntax issue

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.

Frequent Contributor
Posts: 98

Re: PROC FREQ syntax issue

Posted in reply to Astounding
awesome, thanks!
Super User
Posts: 20,203

Re: PROC FREQ syntax issue

Yes it's possible.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

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