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 (September 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 16 Sep 2010 09:55:57 -0400
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Recoding based on frequencies

Hi, Saw this interesting question posted somewhere else. I tried, but could not come up with a neat solution. Can you? Thanks.

"I have a series of categorical variables that I would like to recode based on their frequency/count. [...] So, for example, if I had a series of records in the variable being a, a, a, b, b, c, I would like to recode my variable so that 'a ' (having the highest count) would be coded as 3 and 'c' (having the lowest count) would be coded as 1. Since I have a series of variables it would be hard to recode them manually so was wondering whether there was a command to easily do this."

Below is a test data I made up.

/* test data */ data one; input id (v1-v5) ($); cards; 1 a a a . a 2 a b b . a 3 a c c . a 4 b c d . a 5 b c e . a 6 c c . . a ; run;


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