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

Hello everyone, 

please i have to following dataset. The THCIC_ID variable is the unique ID of each hospital in PROVIDER_NAME variable column. Each observation per hospital is the inidividual patient that was admitted in that hospital. e.g austin state hospital, the first hospital, have 8 admissions. I am asked to provide the mean number of admissions across all hospitals. do i have to create a count ? i dont know how to go about it. There are 361 hospitals and over 9000 observations in the dataset.

Thank you

Olajumoke_0-1633380847646.png

data set

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc freq data=week6.thcics;
    tables provider_name/out=counts noprint;
run;
proc means data=counts;
    var count;
run;
--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

PROC FREQ will determine the actual number of admissions per hospital.

 

To get the mean number of admissions, you would run PROC MEANS on the output of PROC FREQ.

 

 

--
Paige Miller
Banke
Pyrite | Level 9

Thank you. Can you please show me the syntax? 

is it something like

PROC FREQ DATA = WEEK6.THCICS;

TABLES PROVIDER_NAME;

OUTPUT OUT = MEANS MIN MAX;

RUN;

?

 

PaigeMiller
Diamond | Level 26
proc freq data=week6.thcics;
    tables provider_name/out=counts noprint;
run;
proc means data=counts;
    var count;
run;
--
Paige Miller
Banke
Pyrite | Level 9

It worked, thank you

Kurt_Bremser
Super User

You ca run two nested SQL SELECTs.

proc sql;
select mean (count)
from (select hosp_id, count(*) as count from have group by hosp_id);
quit,;

In the future, please supply data in usable form, in a data  step with datalines, not as pictures, so we have something to test against.

Banke
Pyrite | Level 9

Thanks, i do not know how to go about it. t hats why i dont have a data step, i dont know about proc sql yet, can you please explain to me:?

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!

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
  • 6 replies
  • 569 views
  • 1 like
  • 3 in conversation