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 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Sep 2005 12:14:16 -0400
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: divide a data set into 2 subsets
Comments: To: Haigang Zhou <hzhou3@UNLSERVE.UNL.EDU>

Here is a one step solution:

data high low; set income (in=a_) income (in=b_); if a_ then do; total+inc; n+1; end; if b_ then do; if inc > total/n then output high; else output low; end; drop total n; run;

HTH

Ya Huang

On Wed, 7 Sep 2005 11:47:45 -0400, Haigang Zhou <hzhou3@UNLSERVE.UNL.EDU> wrote:

>I want to divide a data set into 2 subsets by the average of a variable. >For example, I have an income data set, and I want to divide it into two >sub sets. High if the income is above average, and low otherwise. I can >achieve the goal using the following code, but I have to manually input >the value for the mean. Is there is a way to do it automatically? I >appreciate your kind help! > >* The raw data; >data income; > input id inc; > cards; > 1 43 > 2 89 > 3 45 > 4 13 > 5 90 > 6 67 > ; > run; > >* Calculate the mean value of income; >proc means data=income; > var inc; > run; > >* I have to manually enter the mean value of income - 57.83; >data high low; > set income; > if inc > 57.83 then output high; > else output low; > run;


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