user3810133
user3810133

Reputation: 31

Sampling from a Normal Distribution in SAS

Suppose I know that the average age of males in a town is 50. The standard deviation is 10. How would I sample an age from this distribution using SAS?

Upvotes: 0

Views: 1509

Answers (2)

Joe
Joe

Reputation: 63434

You can generate random data with that mean/std using the rand function:

%let numsampled=10;
data ages;
 call streaminit(7);  *initialize the seed;
 do id = 1 to &numsampled;
     age = rand('Normal',50,10);    
     output;
 end;
run;
proc print data=ages;
run;

If you want to do more complex sampling, such as generating a set and then sampling with replacement from it, you can first generate a population of N size above, and then use proc surveyselect to pull from that population.

Upvotes: 0

itzy
itzy

Reputation: 11765

In a data step you can use x = rand('NORMAL',50,10). SAS/IML has a different syntax. You may wish to set a random seed using call streaminit.

Upvotes: 2

Related Questions