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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

 

View solution in original post

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

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;

 

 

 

ballardw
Super User

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.

 

JacquesR
Quartz | Level 8

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;
JacquesR
Quartz | Level 8

@ballardw 

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.

SAS Innovate 2025: Register Now

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!

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
  • 5 replies
  • 1185 views
  • 1 like
  • 3 in conversation