Programming the statistical procedures from SAS

Percentiles and Ranks in SAS-9.2

Reply
Super Contributor
Posts: 1,040

Percentiles and Ranks in SAS-9.2

Hi all,

i have 3 variables.

Los index is length  of stay

Hospital     Los Index        Mortality Index

A                 1.12                   1.28

B                 0.14                   0.94

For Hundreds of records like this...

I want to calculate percentiles      10,20 ,25, 30,40,50,60,75,80,90, and 100 th  for this data in SAS

And the ranks of the hospitals

Could somebody help me please..........

Thanks a lot

Valued Guide
Posts: 2,108

Re: Percentiles and Ranks in SAS-9.2

PROC UNIVARIATE and PROC SUMMARY will both get the percentiles for these.  PROC RANK will do the ranks.

Super Contributor
Posts: 1,040

Re: Percentiles and Ranks in SAS-9.2

Hi Doc,

I first use proc univariate on the Los index variable.I will output the percentiles to another dataset,

To the output dataset when i use rank on the same variable i get rankalso in my final dataset.is that  right?????

Thanks a lot

Valued Guide
Posts: 2,108

Re: Percentiles and Ranks in SAS-9.2

no.  run PROC RANK directly against the raw data.

Super Contributor
Posts: 1,040

Re: Percentiles and Ranks in SAS-9.2

SO DO U WANT ME TO RUN THIS CODE AND IT WILL GIVE PERCENTILES AS WELL AS RANKS FOR BOTH OF THESE VARIABLES????????

proc rank data=DSETNAME groups=100 out=ranked_a;

     var LOS_INDEX MORTALITY_INDEX;

     ranks rank_y;

     run;

Thanks

Valued Guide
Posts: 2,108

Re: Percentiles and Ranks in SAS-9.2

That will provide "percentile ranks"; it will not provide ranks as they are normally thought of (sequential number from 1 to <samples size>).

Super Contributor
Posts: 1,040

Re: Percentiles and Ranks in SAS-9.2

Because i wanted 10,20 ,25, 30,40,50,60,75,80,90, and 100 th percentiles

as well as the ranks of each

Valued Guide
Posts: 2,108

Re: Percentiles and Ranks in SAS-9.2

I understand that.  PROC RANKS, as you wrote it, will not provide the ranks, it will provide 'percentile ranks' and they are a bit different.  In order to get both the specified percentiles and the ranks, you need to run two procedures.

Super Contributor
Posts: 1,040

Re: Percentiles and Ranks in SAS-9.2

Great........

Thank you so very much Doc. I appreciate your time on this. Do you also work tomorow?

Ask a Question
Discussion stats
  • 8 replies
  • 538 views
  • 0 likes
  • 2 in conversation