I have a dataset with 9 hospitals and specimen types ranging 0-4 where 4=unsatisfactory. I need to calculate specimen types for each hospital and give rankings to the hospital according to the unsatisfactory specimen(4) percentages. How can we do this?
1. Calculate the percent of unsatisfactory per hospital. Depending on the data this could be proc freq or means.
2. Use PROC RANK to rank the data or order it descending and apply ranks manually.
Example below. Without the information request by @PaigeMiller we won't be able to help you further. Please include your code, log and example data if you run into issues.
proc freq data=hospitalData noprint;
table hospital*specimen / out=hosp_spec outpct;
run;
proc rank data=hosp_spec out=want;
where specimen = '4';
var pct_row;
ranks rank_pct_row;
run;
@SriCh1 wrote:
I have a dataset with 9 hospitals and specimen types ranging 0-4 where 4=unsatisfactory. I need to calculate specimen types for each hospital and give rankings to the hospital according to the unsatisfactory specimen(4) percentages. How can we do this?
@SriCh1 wrote:
I have a dataset with 9 hospitals and specimen types ranging 0-4 where 4=unsatisfactory. I need to calculate specimen types for each hospital and give rankings to the hospital according to the unsatisfactory specimen(4) percentages. How can we do this?
I'm not sure what "calculate" means in this context. Does it mean you need to count the number of unsatisfactory specimens at each hospital? Can you show us a small portion of this data set following these instructions (and not via any other method).
Yes, count the number of unsatisfactory specimens for each hospital, convert it into a percentage, and then give ranking according to the percentage.
Repeating: "Can you show us a small portion of this data set following these instructions (and not via any other method)."
1. Calculate the percent of unsatisfactory per hospital. Depending on the data this could be proc freq or means.
2. Use PROC RANK to rank the data or order it descending and apply ranks manually.
Example below. Without the information request by @PaigeMiller we won't be able to help you further. Please include your code, log and example data if you run into issues.
proc freq data=hospitalData noprint;
table hospital*specimen / out=hosp_spec outpct;
run;
proc rank data=hosp_spec out=want;
where specimen = '4';
var pct_row;
ranks rank_pct_row;
run;
@SriCh1 wrote:
I have a dataset with 9 hospitals and specimen types ranging 0-4 where 4=unsatisfactory. I need to calculate specimen types for each hospital and give rankings to the hospital according to the unsatisfactory specimen(4) percentages. How can we do this?
Please note that in the future, we're going to insist on you providing data according via working SAS data step code (you can follow these instructions), and you will get faster and probably more correct responses by doing so.
As you have provided the data, just change the names of the variables and the names of the input data set in the code from @Reeza to match your variable names. You will need to add the SPARSE option to the TABLES statement.
ERROR: Variable PCT_ROW not found.
Sometimes these things can be solved simply by LOOKING AT the data sets. In this case, please look at the data set NEWBORN.PERCENT and see if the variable name is something other than PCT_ROW. If it is a different name, then use the name that is present in that data set.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.