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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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