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
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
>
|