LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (December 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 19 Dec 2003 06:40:17 GMT
Reply-To:     "Andrew H. Karp" <sfbay0001@AOL.COMNOPE>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Andrew H. Karp" <sfbay0001@AOL.COMNOPE>
Organization: AOL http://www.aol.com
Subject:      Re: function for quartile flags (cut points)

>You should look at PROC RANK. You can split your data into 10 groups >for deciles of variable INCOME like this: > >proc rank data=yourdata out=rankdata groups=10; > var income; > run; > >This will replace INCOME in the output data set with the ranking values, >1 to 10. To do quartiles, just change the first line to GROUPS=4 >instead. > >To keep INCOME and build an INCOMERANK variable with the rank-group >values, create a duplicate variable first, like this: > >data yourview/view=yourview; > set yourdata; > incomerank=income; > run; > >proc rank data=yourdata out=rankdata groups=10; > var incomerank; > run;

Let me please add to David's post on this topic. I prefer to use the RANKS statement in PROC MEANS, in which you give the names of the variable(s) in the output data set that hold/store the rankings generated by the PROC. This avoids either over-writing the values of the analysis variable with their ranks, or having to create a separate variable in a data step before applying PROC RANK.

Here is what I would do:

PROC RANK DATA=yourdata groups=10 our=ranked_data; var income; ranks incomerank; run;

ALL of the variables in "yourdata" will be output to "ranked_data" along with the new variable INCOMERANK, which holds the deciles.

Hope this helps...

Andrew

Andrew H. Karp SAS Certified Professional, Version 8 Sierra Information Services, Inc. 19229 Sonoma Hwy. Sonoma, CA 95476 USA 707/996-7380 SierraInfo@AOL.COM http://www.SierraInformation.com


Back to: Top of message | Previous page | Main SAS-L page