## Looking for Precision Up to Maybe 8 Decimal Places in proc rank

Frequent Contributor
Posts: 115

# Looking for Precision Up to Maybe 8 Decimal Places in proc rank

I use the following code to obtain the percentiles of over 100,000 observations:

proc rank data = CombineScoredTemp groups = 100 out = CombineScoredTemp;

var Predicted_SLR;

ranks Percentile_SLR;

run;

But it provides the percentiles as integers. Any suggestions on how to get a real number out of this?

Thank you, as usual.

Super User
Posts: 13,542

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

Do you mean that you want 0.01000000 instead of 1? Or 1.00000000?

SAS actually does not differentiate between integer and real in its storage. The active display format controls how many, if any, decimals are displayed. Print your resulting set with Format Percentile_slr F16.8 ; to see more decimals.

If you want to know the percentiles as in which value is the 7th percentile you likely need another procedure than rank as except for tie breaking ranks tend to be integer.

Posts: 1,270

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

proc rank ranks data based on Predicted_SLR variable and makes 100 groups each contains around 1000 observations. For percentile try proc univariate.

Super User
Posts: 23,724

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

I think you're looking for the CDF instead:

ods table cdfplot=want;;

proc univariate data=CombineScoredTemp;

var Predicted_SLR;

cdfplot Predicted_SLR;

run;quit;

Frequent Contributor
Posts: 115

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

Thank you for all of the answers. CDF seems to show the most promise. But how may I modify the code to accomodate saving the actual percentile on a record-by-record basis?

This would be the equivalent of a PERCENTRANK() function in Excel.

Thanks.

Super User
Posts: 23,724

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

i'm not sure what your question is. Can you clarify what you mean by saving and row by row? The output dataset has the CDf values for all observations.

Frequent Contributor
Posts: 115

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

I am probably missing something.

I run the following code and it makes a nice CDF plot:

ods table cdfplot = want;;

proc univariate data = CombineScoredTemp;

var Predicted_SLR;

cdfplot Predicted_SLR;

run;

quit;

But it does not add the percentiles to the data file.

Plus, I receive a warning saying that the CDFPlot was not created. I am sure that both of these are related, somehow.

I am pretty sure I just mis-read the supplied code or something. But I am currently lost.

I especially am interested in setting this right as I recently read an article on the web very much trashing the PERCENTRANK() procedure in Excel.

Thank you, as usual.

Super User
Posts: 23,724

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

the ods statement before the proc should store the values in a new table called want.

Super User
Posts: 23,724

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

Depending on SAS version you may need to turn ODS Graphics on;  to see plot.

Posts: 3,852

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

proc stdize pctlpts=1 to 100 data=sashelp.heart outstat=pctls out=_null_;
var height weight diastolic systolic;
run;

Frequent Contributor
Posts: 115

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

What do you think of the following for my solution?

proc rank data = CombineScoredTemp groups = 100000000 out = CombineScoredTemp;

var Predicted_SLR;

ranks PERCENTILE_SLR;

run;

data CombineScoredTemp;

set CombineScoredTemp;

PERCENTILE_SLR = PERCENTILE_SLR / 1000000;

run;

Only problem I see is that it is limited to 6 decimal places. Maybe 7.

Posts: 3,852

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

I thought you wanted to compute the percentiles for Predicted_SLR that can be done in a number of ways in SAS PROC STDIZE being a pretty easy method.

Your PROC RANKS GROUPS=100 is similar in that it groups the observations into "percentile groups".  The computed RANK that you named PERCENTILE_SLR in the RANK statement is not the percentile "value" as computed by PROC STDIZE.

Am I understanding correctly?

Super User
Posts: 23,724

## Re: Looking for Precision Up to Maybe 8 Decimal Places in proc rank

This method does not account for ties. If you have no ties or don't care you can more easily calculate your 'percentiles' using a data step.

Discussion stats
• 12 replies
• 991 views
• 8 likes
• 5 in conversation