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

I have some data that I am analyzing using proc summary.  The following example produces output that is really close to what I need:

data input;

   input source sex $ weight;

   datalines;

176 M 2240

176 F 1814

177 M 2380

177 F 1910

178 M 2190

178 F 1790

179 M 2250

179 F 1850

;

run;

proc summary data=input;

   class source sex;

   var weight;

   output out=summary mean=weight cv=cv n=no;

run;

proc print data=summary noobs;

run;

I would like to group some of the class data together so that the output includes the "176+177" lines shown below:

sourcesex_TYPE__FREQ_weight   cv  no
.           0     8   2053 11.4592 8
F    1     4   1841  2.8350 4
M    1     4   2265  3.5777 4
  176           2     2   2027 14.8608 2
  177           2     2   2145 15.4937 2
  176+177       2     4   2075 15.1234 4
  178           2     2   1990 14.2132 2
  179           2     2   2050 13.7972 2
  176  F    3     1   1814   .     1
  176  M    3     1   2240   .     1
  177  F    3     1   1910   .     1
  177  M    3     1   2380   .     1
  176+177  F    3     1   1860
  176+177  M    3     1   2310
  178  F    3     1   1790   .     1
  178  M    3     1   2190   .     1
  179  F    3     1   1850   .     1
  179  M    3     1   2250   .     1

The only way I can think of doing that is to use several data steps to combine the values for several of my sources and then append the combined data to my original data before running through proc summary.  Is there a more elegant approach?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Use a multilabel format in proc means (rather than summary). I think most of the code will stay the same though between the two procedures.

Base SAS(R) 9.3 Procedures Guide, Second Edition

View solution in original post

4 REPLIES 4
Reeza
Super User

Use a multilabel format in proc means (rather than summary). I think most of the code will stay the same though between the two procedures.

Base SAS(R) 9.3 Procedures Guide, Second Edition

data_null__
Jade | Level 19

MULTILABEL formats work in PROC SUMMARY.  PROC MEANS and PROC SUMMARY are the same program.

Reeza
Super User

Thanks, are they always interchangeable?

data_null__
Jade | Level 19

The defaults are different. 

The documentation for PROC SUMMARY is basically "see proc means"

Base SAS(R) 9.3 Procedures Guide, Second Edition

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