BookmarkSubscribeRSS Feed
shorty_tallz
Calcite | Level 5

Hello world,

I'm currently trying output a summary of an existing dataset into a new file (containing only only the summary values).  I've tried using the class specifier to summarize (mean, sum, etc.) each variable by date, but after checking the output file, I noticed it still retained each original observation instead of summarizing by date.  Thanks in advance for any help!

-John

Here's my code (mtsudat library is already referenced): 

proc summary data = sasuser.marchflights maxdec=2 sum mean;

  class date;

  var distance mail freight boarded transferred nonrevenue passengercapacity;

output out = mtsudat.marchflights;

run;

3 REPLIES 3
OS2Rules
Obsidian | Level 7

Try:

proc summary data = sasuser.marchflights maxdec=2 sum mean;

  class date;

  var distance mail freight boarded transferred nonrevenue passengercapacity;

output out = mtsudat.marchflights (drop=_TYPE_ _FREQ_) SUM=;

run;

DLing
Obsidian | Level 7

proc summary data=sasuser.marchflights missing;     *--- missing option outputs missing class values as well;

     class date;                                    *--- you can attach formats to dates to get monthly, qtrly summaries easily;

     var x1 x2 x3;

     output out=mtsudat.marchflightsummary(drop=_:)     /*  drop _type_ _freq_  */

          sum=x1sum x2sum x3sum

          n=x1n x2n x3n

          std(x1)=x1std

     ;

run;

proc summary by default prints nothing, so maxdec=2 has no effect, nor does the mean option.  They are meaningful for PROC MEANS printed output.

Ksharp
Super User

You should use nway option and define the sum  mean ... at output statement.

proc means noprint data=sashelp.class maxdec=2 sum mean nway;
 class sex;
 var weight height;
 output out=want sum= mean= /autoname;
run;


Ksharp

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 1426 views
  • 0 likes
  • 4 in conversation