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

Please, i have a data set for hospital records, there are many patients that have a particular diagnosis. i am aked to provide the average length of stay of the patients per diagnosis. Is there a way i can have a table that shows the mean of the patients per diagnosis?

 

i tried this and it did not work, the codes in the parentheses are the diangosis codes in the variable Admitting_diag. i am to findthe mean legth of stay per the admitting diagnoses

 

PROC MEANS DATA = WEEK6.QUES3B1 MEAN MIN MAX MAXDEC = 1;
VAR LENGTH_OF_STAY;
WHERE ADMITTING_DIAG IN ('V3000') OR ADMITTING_DIAG IN ('V221') ;
RUN;

i also tried where admitting_diag in WHERE ADMITTING_DIAG IN ('V3000' 'V221' 'V3001' '650' '78650')

all it gave me is the cummulative mean for all diagnoses in the parenthesis


WHERE ADMITTING_DIAG IN ('V3000' 'V221' 'V3001' '650' '78650');
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
mkeintz
PROC Star

You must tell proc means that you expect it to produce results for each value of ADMITTING_DIAG.  Use the CLASS statement, as in:

 

PROC MEANS DATA = WEEK6.QUES3B1 MEAN MIN MAX MAXDEC = 1 nway;
VAR LENGTH_OF_STAY;
class admitting_diag;
WHERE ADMITTING_DIAG IN ('V3000' 'V221' 'V3001' '650' '78650');
RUN;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

View solution in original post

1 REPLY 1
mkeintz
PROC Star

You must tell proc means that you expect it to produce results for each value of ADMITTING_DIAG.  Use the CLASS statement, as in:

 

PROC MEANS DATA = WEEK6.QUES3B1 MEAN MIN MAX MAXDEC = 1 nway;
VAR LENGTH_OF_STAY;
class admitting_diag;
WHERE ADMITTING_DIAG IN ('V3000' 'V221' 'V3001' '650' '78650');
RUN;

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 375 views
  • 0 likes
  • 2 in conversation