06-15-2017 05:49 AM - edited 06-15-2017 05:59 AM
In the attached data set , I am trying to find the hospital that has got more number of patients? The solution that have below seems to be long. Can someone please suggest the best/ easy way to solve this? Thank you.
proc means data=mylib1.claim nway order =freq;
output out =temp;
where _stat_= "N";
drop _freq_ _type_ _stat_;
06-15-2017 05:56 AM
Sorry, this s how the sample data looks like:
06-15-2017 05:54 AM
Seems fine to me other than your missing a "run;" at the end of each step - not required, but good practice. What do you think is long about it, you don't need the second statement, just wrap that into further processing.
No dataset attached by the way, and post test data in the form of a datastep anyway.
06-15-2017 06:02 AM
Thank you for your response. Sorry missed data earlier.
I provided the sample data in the previous post now.
Do you mean dont need data step? If I only use the first proc step, get N, Mean, median and standard deviation in the result set. How do ignore them and only keep the number of observations/ count for each hospital?
06-15-2017 06:18 AM
You can select summary stats on the output step (and add noprint to supress the text output) - note below how I present test data, please provide like this in future.
data claim; input BenefUserID HospId $; datalines; 108 HopID-399 114 HopID-279 117 HopID-32 141 HopID-45 147 HopID-258 148 HopID-846 159 HopID-499 186 HopID-490 ; run; proc means data=claim nway order=freq noprint; class Hospid; var BenefUserID; output out=temp n=n; run;
06-15-2017 06:37 AM
Thank you, I will keep the dataset in mind in the future.
Btw, I still get _type_ and _freq_ columns in the outout screen. How do I get rid of them and only show Hospital and number of observations? Can I use drop here?
Need further help from the community? Please ask a new question.