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;
class Hospid;
var BenefUserID;
output out =temp;
data temp1;
set temp;
where _stat_= "N";
drop _freq_ _type_ _stat_;
Use DROP like this
proc means data=claim nway order=freq noprint;
class Hospid;
var BenefUserID;
output out=temp(drop = _FREQ_ _TYPE_) n=n;
run;
I don't see any attached dataset? Please provide sample data in the form of a datastep
Sorry, this s how the sample data looks like:
BenefUserID | HospId |
108 | HopID-399 |
114 | HopID-279 |
117 | HopID-32 |
141 | HopID-45 |
147 | HopID-258 |
148 | HopID-846 |
159 | HopID-499 |
186 | HopID-490 |
192 | HopID-399 |
194 | HopID-138 |
195 | HopID-399 |
224 | HopID-13 |
242 | HopID-231 |
247 | HopID-45 |
250 | HopID-154 |
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.
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?
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;
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?
Use DROP like this
proc means data=claim nway order=freq noprint;
class Hospid;
var BenefUserID;
output out=temp(drop = _FREQ_ _TYPE_) n=n;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.