Hello
I am trying to group by the output of a PROC REPORT (based on the below example, I'd like to only show 4 rows, rather than repeating the APPs)
data have; input DT$ APP$ Arrived$; datalines; JAN19 APP1 Y JAN19 APP2 Y JAN19 APP3 Y JAN19 APP4 N FEB19 APP1 N FEB19 APP2 Y FEB19 APP3 Y FEB19 APP4 Y MAR19 APP1 Y MAR19 APP2 Y MAR19 APP3 N MAR19 APP4 N ;run; proc report data=have nowd; column APP (DT, Arrived) ; define DT / across 'DT' ORDER=DATA; ; quit;
I have tried many different combinations but I cannot get the right syntax (my main issue seems to be that the variable "Arrived" is not a numeric; for example if I add
define APP / group 'APP';
it complains I don't have any statistics associated.
Many thanks
Hi @MART1
You can try this:
proc report data=have nowd;
column APP (DT, Arrived) ;
define DT / across 'DT' ORDER=DATA;
define APP/ group;
define Arrived / group;
quit;
You haven't explained the output that you want to get from PROC REPORT. What are the rows? What are the columns? What number should appear in each "cell"?
Do you want counts in each "cell"? PROC FREQ will do this.
Hi @MART1
You can try this:
proc report data=have nowd;
column APP (DT, Arrived) ;
define DT / across 'DT' ORDER=DATA;
define APP/ group;
define Arrived / group;
quit;
No complaint about the DT values not being in date order?
@ballardw wrote:
No complaint about the DT values not being in date order?
Right. As soon as the data set has APR19 the ordering is screwed up. Better would be to convert JAN19, FEB19 etc. to actual SAS date values instead of text strings, and then this ordering issue is easily handled.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.