Hi all
I have a number of time variables (all formatted time9.), and I would like the get a summary of them.
PROC MEANS
DATA=Test
N MIN Q1 MEDIAN Q3 MAX MEAN ;
VAR TimeIngestionToNAC TimeIngestionToMeth TimeIngestionToAntidote TimeAdmissionToNAC TimeAdmissionToMeth TimeAdmissionToAntidote ;
RUN;
But that does not show the time-formatted values in the columns.
How do I get the same layout in PROC REPORT?
PROC REPORT
DATA=Test;
COLUMN (MIN Q1 MEDIAN Q3 MAX MEAN), TimeIngestionToNAC ...?;
RUN;
It seems to me as if I am missing something incredibly simple as I read the documentation, because I feel it should be easy to get this, but I don't see how.
Thanks
In Report you don't, because report doesn't like to stack variables.
Try
PROC MEANS DATA=Test N MIN Q1 MEDIAN Q3 MAX MEAN stackods ; VAR TimeIngestionToNAC TimeIngestionToMeth TimeIngestionToAntidote TimeAdmissionToNAC TimeAdmissionToMeth TimeAdmissionToAntidote ; ods output summary= work.summary; RUN;
Which will place the output into a data set that is structured similar to the proc means results.
Then use Proc Print with appropriate format for the statistics.
Do you run both steps against table TEST?
Like this?
proc summary data=SASHELP.CLASS min max mean ;
var AGE WEIGHT HEIGHT;
output out=SUM;
run;
proc transpose data=SUM out=TRANSP;
id _STAT_;
run;
proc print;
run;
In Report you don't, because report doesn't like to stack variables.
Try
PROC MEANS DATA=Test N MIN Q1 MEDIAN Q3 MAX MEAN stackods ; VAR TimeIngestionToNAC TimeIngestionToMeth TimeIngestionToAntidote TimeAdmissionToNAC TimeAdmissionToMeth TimeAdmissionToAntidote ; ods output summary= work.summary; RUN;
Which will place the output into a data set that is structured similar to the proc means results.
Then use Proc Print with appropriate format for the statistics.
Thanks @ballardw
I wasn't aware of stackods. That's a nice one for the repertoire.
I added, as you suggested:
proc print noobs data=work.summary;
format Min--Mean time9.;
run;
I realised I could get the same effect like this:
proc tabulate
data=Test;
var TimeIngestionToNAC TimeIngestionToMeth TimeIngestionToAntidote
TimeAdmissionToNAC TimeAdmissionToMeth TimeAdmissionToAntidote ;
table TimeIngestionToNAC TimeIngestionToMeth TimeIngestionToAntidote
TimeAdmissionToNAC TimeAdmissionToMeth TimeAdmissionToAntidote
,N (MIN Q1 MEDIAN Q3 MAX MEAN)*f=time9. ;
run;
Which does get it done in one step.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.