BookmarkSubscribeRSS Feed
Nieves
Quartz | Level 8

Hi SAS experts,

 

I create percentile of var1 using the following code. However, the number of observation in the top 90 percentile or bottom 10 percentile does not equal to 10% of the total observation. May I ask is there an error in my code ?  Thanks! 

 

proc univariate data = tmp1 noprint;

by date;

var var1;
output out = ret_cuts pctlpre=retp_ pctlpts=10,90;

run;

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

Your code looks fine to me? Changing the data set and variables to SAS data sets we can all access yields a correct result?

 

proc univariate data = sashelp.iris noprint;
by species;
var sepallength;
output out = ret_cuts pctlpre=retp_ pctlpts=10,90;
run;
Nieves
Quartz | Level 8

@PeterClemmensenThanks for your reply. 

 

I might have a lot of values of variable equal to the 90 percent cut off value. Could this be the reason why number of observation above 90 percentile larger than 10% of total observation ? May I ask how to increase the number of digit in the variable of interest, so that the precision will increase ? 

 

Thanks 

FreelanceReinh
Jade | Level 19

@Nieves wrote:

I might have a lot of values of variable equal to the 90 percent cut off value. Could this be the reason why number of observation above 90 percentile larger than 10% of total observation ?


Yes, this is a plausible reason.

@Nieves wrote:

May I ask how to increase the number of digit in the variable of interest, so that the precision will increase ? 

 


How do you select the observations from the top and bottom decile? Normally, this selection would be based on the internal values of the variable of interest. Hence, the full precision would be used and no "hidden digits" would be left to serve as tie breakers. Can you  obtain more precise values from the data source? Could another variable serve as a tie breaker? Or would it make sense for your application to take a random sample from the (identical) values at the cutoff in order to get as close to a 10% subset as possible?

sas-innovate-2024.png

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.

 

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
  • 3 replies
  • 636 views
  • 1 like
  • 3 in conversation