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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1803 views
  • 7 likes
  • 5 in conversation