BookmarkSubscribeRSS Feed
Crubal
Quartz | Level 8

Hi,

 

I have a data set named A including two columns: 

 

Dataset.PNG

Dataset2.PNG

 

I wuld like to draw histogram which reflects 'Booking_Lead' and its corresponding 'Avg_Percent'. Besides, I would like to draw a 90% quantile that starting from the largest 'Booking_Lead', and in this example, it is between 0 and 1, but near 1. And output the result called Table B. 

 

I have tried the following: 

 

ods graphics off;

proc univariate data=A noprint;
var Booking_Lead;
histogram Booking_Lead /BARLABEL=percent STATREF=P 90 STATREFLABEL="90th Pctl";
output out=B p90=p90pct;
run;

 

But this is not correct, How could I change the code, please?

 

Thank you! 

3 REPLIES 3
Rick_SAS
SAS Super FREQ

It looks like your data is a summarization of the raw data. Does the avg_percent column sum to 1? Do you have the raw data?  If so, please post as a DATA step, not as an image file. 

 

If you don't have the raw data, then compute the cumulative proportions by summing the avg_percent column:

data want;

set A;

cum_percent + avg_percent;

run;

 

The first observation for which cum_percent >= 0.9 is an estimate of the 90th percentile.

 

Crubal
Quartz | Level 8

Hi Rick,

 

Thank you!  The 'Avg_Percent' column sum to 1. And my prior code to obtain this data is as below:

 

Proc Sql;
Create Table Work.A
as select distinct
Operating_Div_CD,
Chain_Cd,
LOC_ID,
Booking_Lead,
avg(Percentage) as Avg_Percent
from Work.A_1
group by 1, 2, 3, 4
order by 4 desc;
Quit;

 

And I figured out the corresponding 'Booking_Lead' versus 90% quantile from your hint. 

 

Thank you 

 

Rick_SAS
SAS Super FREQ

The simpler way is to use 

proc histogram data=A_1;

histogram Percentage;

etc.

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
  • 942 views
  • 1 like
  • 2 in conversation