Hello,
I need to find outliers using the Interquartile Range(IQR) but first I have to count first and the third quartile. How can I achieve this in easly way? Also I want to group my calculation. Let's say I have example data like below:
data HAVE;
input FRUIT $ COUNT;
datalines;
Apple 2
Apple 5
Apple 7
Apple 9
Apple 19
Banana 1
Banana 3
Banana 3
Banana 5
Banana 8
;
What I've done is:
PROC MEANS data=HAVE q1 q3 ;
BY FRUIT;
VAR COUNT;
RUN;
But what I got is a proc means report, I need results in table to refer to them further like:
data WANT;
input FRUIT $ Q1 Q3;
datalines;
Apple 5 9
Banana 3 5
;
I've found solution myself. It's possible to add output function to proc means procedure.
PROC MEANS data=HAVE;
BY FRUIT;
VAR COUNT;
output out=FRUIT_CALC Q1= Q3= /autoname;
RUN;
A few pointers to help you get an answer faster
The description of what you want might be obvious to you, but it is unclear to me (and probably others)
Thanks
I've found solution myself. It's possible to add output function to proc means procedure.
PROC MEANS data=HAVE;
BY FRUIT;
VAR COUNT;
output out=FRUIT_CALC Q1= Q3= /autoname;
RUN;
You could get " Interquartile Range(IQR) " directly.
proc summary data=sashelp.heart nway;
class status;
VAR height;
output out=FRUIT_CALC qrange= /autoname;
RUN;
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!
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.