BookmarkSubscribeRSS Feed
UniversitySas
Quartz | Level 8
data temp;
infile DATALINES dsd missover;
input ID DATE var1;
CARDS;
01, 1, 4,
01, 2, 2,
02, 1, 3,
02, 2, 15,
02, 3, 2,
03, 1, 5,
03, 2, 12,
;
run;

Is there a way I can get an output so that I get a new column, which tells me the percentile rank (2 decimal places?)  of var1, based on date?

 

So it would look at date 1, and for each id, calculate a percentile rank and output that as the next column?

Then for date 2, the next percentile rank of var1 is output underneath, and so on?

 

data temp;
infile DATALINES dsd missover;
input ID DATE var1 percentile;
CARDS;
01, 1, 4, 66.66
01, 2, 2, 0
02, 1, 3, 0
02, 2, 15, 100
02, 3, 2, 100
03, 1, 5, 100
03, 2, 12, 66.66
;
run;

I just did rough calculations, so apologies if the numbers are incorrect, but hopefully you get the idea.

1 REPLY 1
ballardw
Super User

I think that you need to go into a little bit of detail as to how you arrived at those "percentile" rough estimates.

Since every one of the records you show has exactly one id and date if the percentile is supposed to be by Id and Date then the single value shown for Var1 is any percentile. You mention in your subject line by "time" but your data doesn't show a "time" value but a date. So I have to assume date is the time. But you do not describe what role the ID has in the process. If none, then do not include the ID at all. If the process is supposed to use the ID then tell us how.

 

Percentiles are order statistics and result in indicating a value that exists in the data (or with typical tie breaking rules the average between two values . Typically if you have values like: 1 2 3 4 then the 50th percentile [middle] falls between 2 and 3 so 2.5 might be reported, or 2 or 3 if using lower/upper rules).

 

So none of the "percentiles" you show are typical for standard definitions of percentile.

If you meant "percentage" then we would need to know what goes into the numerator and denominator and that is not at all obvious.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 433 views
  • 0 likes
  • 2 in conversation