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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.