🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 11-23-2021 05:46 AM
(6742 views)
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
;
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A few pointers to help you get an answer faster
- Provide the "have" data in code form. That way we can cut/paste it into SAS and not spend time writing the code to generate the "have" data
- Provide the "want" data i.e. what you want the output data to look like
- Provide what you have tried so far
The description of what you want might be obvious to you, but it is unclear to me (and probably others)
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are right, my post was chaotic. I corrected it on your advice. My result is in the form of a report and I would like to have it listed in the table because I want to refer to these results from quartiles 1 and 3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You could get " Interquartile Range(IQR) " directly.
proc summary data=sashelp.heart nway;
class status;
VAR height;
output out=FRUIT_CALC qrange= /autoname;
RUN;