Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quartile 2

Status
Not open for further replies.

DonaZ

Technical User
Oct 10, 2007
41
US
I need help on quartiles.
Where do I start? I have the mean. I need the 25% and 75% range.

Thank you in advance for your time.
 

You can use proc summary which displays all the summary statistics by default including the quartiles but this may be too much of output to look at. To avoid this, you can use proc univariate in which you can request specific statistics like Q1 and Q3 so that you get to see only what you want.
 
Also, if you want to divide your data into quartiles, you can use the following:-
Code:
proc rank data=orders groups=4 out=ranks_1;
  var frequency value;
  ranks  rank_frequency rank_value;
run;
This will attempt to give you roughly equal sized groups of records numbered 0 to 3. Note that if there are alot of records with identical values of the variable being ranked, you'll end up with uneven sized groups as these won't be split up.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
You can also use proc means to find p25 and p75.

proc means data=work.table p25 p75;
class field1
var value
run;

I've never used proc summary like vuppalanchi suggested, so I can't give a honest comparison of which works best.
 
dlan,
What does class mean?
I did not use class field.

This what I used and it worked.
Proc means data = /*table name*/ n mean p25 p75;
Var /*field name*/;
Run;

donaz
 
DonaZ,
The class option allows you to break out subgroups from the data. This is nice when you have a table with more than one group, and you want to find stats on all the groups. For example, if you had a table with 2 columns:

DayOfWeek Calls
Monday 6
Monday 7
Tuesday 8
Tuesday 9

You can have:
Proc means data=/*table name*/ n mean p25 p75;
Class DayOfWeek;
Var Calls;
run;

the output would be something like:
DayofWeek Mean_Calls P25 P75
Monday 6.5 6 7
Tuesday 8.5 8 9

Without the Class, the out is like this:
Mean P25 P75
7.5 6 9


 
dblan,

What if I have three columns? Could I select only those who attended and still group by class?

donaz
 
What if I have three columns? Could I select only those who attended and still group by class?"

Correct. You can have more than two columns in your table, in fact, there shouldn't be a limit on the number of columns in the table you are using.

Also with mentioning...you can also list two class fields.
To add on the above example...say there was a field called "month" that had "Jan","Feb" as contents.

Proc means data=/*table name*/ n mean p25 p75;
Class Month DayOfWeek;
Var Calls;
run;

And it will can further add detail to you subgroups:

Month DayofWeek Mean_Calls P25 P75
Jan Monday 3.5 2 8
Jan Tuesday 9.5 5 12

Feb Monday 7.5 6 7
Feb Tuesday 4.5 8 9
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top