SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 6743 views
  • 1 like
  • 3 in conversation