Date: Sat, 27 Jan 2007 15:50:54 -0500
Reply-To: Keith Wright <kwright8@ATT.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Keith Wright <kwright8@ATT.NET>
Subject: ranuni - simulation data help
Content-Type: text/plain; charset="iso-8859-1"
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