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

You can add  one or more 'by' variables to almost every SAS proc.

Reeza
Super User

If you're doing unique counts you probably want to look at proc freq or proc sql with count distinct instead of proc means.

Generally its a two step proc freq procedure or a single proc sql procedure. Depending on the data of course.


thdang
Calcite | Level 5

Thank you. But what I also mean is that before I have 1 summary table for the whole data set (30 years of data). Is that also possible to have several tables of summary each for 5 years interval (thus 6 tables)?

Reeza
Super User

Then Art is correct, add a by statement.

art297
Opal | Level 21

You will probably also need a format to define your groups.  If you use a by statement you will get the desired groupings.  If you use a class statement instead (i.e., replace the word by with the word class), you will get an extra line that shows the grand totals:

data have;

  do year=1983 to 2012;

    do i=1 to 19;

      set sashelp.class point=i;

      output;

    end;

  end;

  stop;

run;

proc format;

  value years

  1983-1987='1983-1987'

  1987-1992='1987-1992'

  1993-1997='1993-1997'

  1998-2002='1998-2002'

  2003-2007='2003-2007'

  2008-2012='2008-2012'

  ;

run;

proc means data=have min max mean median stackods;

  var height weight;

  weight age;

  by year;

  format year years.;

  output out=sample_summary median= mean= min= max= stddev= /autoname;

run;

thdang
Calcite | Level 5

Thank you very much!

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!

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
  • 20 replies
  • 1965 views
  • 7 likes
  • 5 in conversation