LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 27 Jan 2007 16:34:48 -0500
Reply-To:     "data _null_;" <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_;" <datanull@GMAIL.COM>
Subject:      Re: ranuni - simulation data help
Comments: To: Keith Wright <kwright8@att.net>
In-Reply-To:  <000d01c74254$d6c24350$2301a8c0@KeithWright>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Try the RANTBL function.

data work.education; /*1: 40% of the time, 2: 20% of the time, 3: 10% of the time, 4: 5% of the time an 5: 25%*/ do obs = 1 to 300; education = rantbl(0,.4,.2,.1,.05); output; end; run; proc freq; tables education; run;

On 1/27/07, Keith Wright <kwright8@att.net> wrote: > Please help. I am new to SAS, and I am trying to generate 300 observations with specific proportions based on education level. > > I would like for education level to equal 1: 40% of the time, 2: 20% of the time, 3: 10% of the time, 4: 5% of the time an 5: 25% of the time. My code is below, but it is giving me the following, please advise where I am going wrong.... > > I am getting the following for education level 1: 41.33 2: 16.67 3: 9.67 4: 7.33 5: 25 > > > data k1; drop num; > > do id = 1 to 300; > > num = ranuni(0); > > if num lt .4 then educ_lev = 1; > > else if num ge .4 & num lt .6 then educ_lev = 2; > > else if num ge .6 & num lt .7 then educ_lev = 3; > > else if num ge .7 & num lt .75 then educ_lev = 4; > > else educ_lev = 5; > > output; > > end; > > > > Thanks > > Keith D Wright > Georgia State Univ. > Graduate Research Assistant >


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