Hi everyone,
I'm in a data management class right now and have been given the following assignment:
Create a temporary SAS dataset with 7000 observations containing a numeric subject number (beginning with 1), a randomly generated marital status (use CALL STREAMINIT and the RAND function with a uniform distribution) with the following proportions: married 65%, single 25%, divorced 10% and a randomly generated age (integer) ranging from 25 to 50 inclusive. Compute the frequencies for marital status and age to confirm values have been appropriately assigned. Print the first 20 observations. {BONUS 5 points: review and comment on the relationship between age and marital status. Within each age, is marital status approximately 65% married, 25% single, and 10% divorced? Why or why not?}
I have thus far developed the following code:
data temp;
call streaminit(1234567);
do Subj = 1 to 7000;
marital = ceil(rand("uniform", 0, 3));
age = ceil(rand("uniform", 24, 50));
output;
end;
run;
proc freq data = temp;
tables marital age;
run;
How can I adjust the proportions of the marital variable so that the random numbers generate in the specified proportions described above? They are currently generating in a 33% proportion for each number 1-3.
Thank you.