BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I know this is going to be a BASIC question for everyone here but I have to ask it, so please forgive ... I'm a new user.

I am trying to do a basic Proc Means data extraction for a data set by certain fields needed for Survival Analysis. I am using the following code:

Proc Means N Median Min Max LCLM UCLM;
var ANC500;
Where Cens_ANC28 = 0;
CLASS BMTTYPE;
Run

This works fine, but what I also need to do is run the same with more than one Class so that it combines them (i.e. I could add "By Yr" to the top but that gives me for each year what the BMTTYPE was and I need the stats for them combined.). I tried to add two classes but it doesn't work, even though I see examples online of this process. I tried adding all of them to the Sort field and still nothing.

Anyone know what I am doing wrong?

TIA
3 REPLIES 3
Cynthia_sas
Diamond | Level 26
Hi:
PROC MEANS allows you to specify 2 class variables on the CLASS statement, as shown in the code below.
[pre]
CLASS YR BMTTYPE;
[/pre]

In order to tell MEANS how to combine the CLASS variables, you would use either the TYPES or WAYS statement. For example:
[pre]
WAYS 1;
WAYS 0 1 2;
[/pre]

WAYS 1 would give you all the 1-way tables. While WAYS 0 1 2 would give you an overall summary, the 1-way tables and the 2-way tables. Without any other instructions from you, PROC MEANS is giving you the "highest" combination of the CLASS variables. If you want other levels of combination, you need to specify those levels. Here's some doc on the topic:
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000222730.htm
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000222729.htm
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/a000146731.htm

cynthia
deleted_user
Not applicable
Where would the WAYS statement come in the syntax?
Doc_Duke
Rhodochrosite | Level 12
Unless the documentation specifies otherwise, anywhere between the PROC statement and the QUIT; or RUN; statement. Suggest you read all the documentation for PROC MEANS.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1634 views
  • 0 likes
  • 3 in conversation