BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
grace999
Obsidian | Level 7

Assume a random variable follow normal distribution with mean 10, std 7, and I would like to know the 80 percentile value. I use quantile('normal', 0.8, 10, 7) get 15.89134864. I have a bunch of random variables with different mean and std, and I tried quantile('normal', 0.8, mean, std) but does not work. 

data have;

input randvar $1 mean:comma3. std comma3.;

datalines;

a 10 7

b 10 8

c 11 6

; run;

 

how do I get the table below? Thanks.

randvarmeanstdpct80
a10715.89134864
b10816.73296987
c10615.0497274
 
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @grace999,

 

Can you be more specific regarding what "does not work"? Please post the log if you get error messages or the results if they are unexpected. Using your dataset HAVE the code below creates the table you want:

 

data want;
set have;
if randvar='c' then mean+(-1);
pct80=quantile('normal', 0.8, mean, std);
run;

proc print data=want noobs;
format pct80 best11.;
run;

(I used an IF-THEN statement to modify the third mean value according to your table. Maybe it was just a typo.)

 

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @grace999,

 

Can you be more specific regarding what "does not work"? Please post the log if you get error messages or the results if they are unexpected. Using your dataset HAVE the code below creates the table you want:

 

data want;
set have;
if randvar='c' then mean+(-1);
pct80=quantile('normal', 0.8, mean, std);
run;

proc print data=want noobs;
format pct80 best11.;
run;

(I used an IF-THEN statement to modify the third mean value according to your table. Maybe it was just a typo.)

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 781 views
  • 0 likes
  • 2 in conversation