Hello,
I would like to get a scatter plot with a mean for the middle line and 90% for the outline. Is there a way to approach it? Thanks.
That's much clearer, but really, that should have been your original explanation. We shouldn't have to repeatedly ask for details and repeatedly ask for clarification. We request that from now on you provide much clearer and more complete problem descriptions in your original problem description.
One thing I am assuming is that for IQR, you want the plot to show the 25%-ile and 75%-ile, and not the actual IQR, which is the subtraction of the two. But you didn't really say that.
proc summary data=sashelp.class;
var height weight;
output out=_stats_ mean(height)=x_mean p25(weight)=y_p25 p75(weight)=y_p75 p90(weight)=y_p90;
run;
data _null_;
set _stats_;
call symputx('x_mean',x_mean);
call symputx('y_p25',y_p25);
call symputx('y_p75',y_p75);
run;
proc sgplot data=sashelp.class;
scatter x=height y=weight;
refline &x_mean/axis=x;
refline &y_p25 &y_p75/axis=y;
run;
To find X above the 90th percentile of Y
data want;
if _n_=1 then set _stats_ (keep=y_p90);
set sashelp.class;
where x>y_p90;
run;
Mean of what? 90% of what? Can you show us an example of this plot?
What is "IQR 90"? Does it refer to the variable on the X-axis or the variable on the Y-axis, or something else?
Repeating:
Can you show us an example of this plot?
IQR is usually interquartile range, 90 is usually 90th percentile.
Which of the two are you asking for?
Yes, this can be done, use REFLINE/BAND statements and pre-calculate your statistics and add them to the data set.
So you want a scatter plot with mean of X and IQR 90 of Y? You still have not explained what IQR 90 is.
That's much clearer, but really, that should have been your original explanation. We shouldn't have to repeatedly ask for details and repeatedly ask for clarification. We request that from now on you provide much clearer and more complete problem descriptions in your original problem description.
One thing I am assuming is that for IQR, you want the plot to show the 25%-ile and 75%-ile, and not the actual IQR, which is the subtraction of the two. But you didn't really say that.
proc summary data=sashelp.class;
var height weight;
output out=_stats_ mean(height)=x_mean p25(weight)=y_p25 p75(weight)=y_p75 p90(weight)=y_p90;
run;
data _null_;
set _stats_;
call symputx('x_mean',x_mean);
call symputx('y_p25',y_p25);
call symputx('y_p75',y_p75);
run;
proc sgplot data=sashelp.class;
scatter x=height y=weight;
refline &x_mean/axis=x;
refline &y_p25 &y_p75/axis=y;
run;
To find X above the 90th percentile of Y
data want;
if _n_=1 then set _stats_ (keep=y_p90);
set sashelp.class;
where x>y_p90;
run;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.