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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 699 views
  • 0 likes
  • 2 in conversation