BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PatrykSAS
Obsidian | Level 7

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
PatrykSAS
Obsidian | Level 7

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;

View solution in original post

4 REPLIES 4
AMSAS
SAS Super FREQ

A few pointers to help you get an answer faster

 

  1. 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
  2. Provide the "want" data i.e. what you want the output data to look like
  3. 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

PatrykSAS
Obsidian | Level 7
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.
PatrykSAS
Obsidian | Level 7

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;
Ksharp
Super User

You could get " Interquartile Range(IQR) " directly.

 

proc summary data=sashelp.heart nway;
class status;
VAR height;
output out=FRUIT_CALC qrange= /autoname;
RUN;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 4136 views
  • 1 like
  • 3 in conversation