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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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