Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to create a simulation variable in a specific range

Status
Not open for further replies.

debdanak

Technical User
Jan 15, 2009
3
IL
I want to create a simulated variable from a normal distribution. I know the mean and the standard deviation of this variable.
I want this variable to be between 1000 and 50000.
how should I do?
 
I know the rand function.
My question is that i need this variable to be between a specific range for example 1000<=x<= 50000.
 
i would specify a mean of 25,500 (50000/2 + 1000/2) and a standard deviation big enough to spread the random variates from 1000 to 50000. An SD aroud 8000 will get you in the ballpark, but to my knowledge there's no way to restrict random variates in SAS to a specified range. You can discard the outliers i guess.
 
Here's one thing you can try....specify a larger standard deviation and discard the outliers. The shaprio-wilkes test for normality has a very high p-value (>.95) indicating perfect normality:

data sim;
do i=1 to 1000;
x = rand('NORMAL', 25500, 10000);
if 1000 <= x <= 50000 then output;
end;
run;

proc univariate data = sim normal plot;
var x;
run;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top