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

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_;

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

I don't see any attached dataset? Please provide sample data in the form of a datastep

vanaml
Calcite | Level 5

Sorry, this s how the sample data looks like:

BenefUserIDHospId
108HopID-399
114HopID-279
117HopID-32
141HopID-45
147HopID-258
148HopID-846
159HopID-499
186HopID-490
192HopID-399
194HopID-138
195HopID-399
224HopID-13
242HopID-231
247HopID-45
250HopID-154
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

vanaml
Calcite | Level 5

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?

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
vanaml
Calcite | Level 5

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?

PeterClemmensen
Tourmaline | Level 20

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 909 views
  • 0 likes
  • 3 in conversation