Hi.
I think your biggest problem is to define mu and sigma of Normal Distribution.
Your mean " the range of random numbers is 1-9 " ,That is to mean mu=5, sigma is not quit sure,
because basing my statistical knowledge , the valuefrom normal will 99.7% probability fall in between mu-3*sigma and mu+3*sigma (e.g ~N(0,1) ,the value will 99.7% probability fall in -3 and 3).
So if as the rule of 3*sigma then sigma will be about 1.4, to make sure value fall in 1-9,
I set sigma = 1.2, or you can change it more little.
Remember sigma is relation with mu for your situation ( from 1-9).
Another problem is arithmetic mean,Are you to mean (1+2+3+4)/4 ?
In numeric calculated ,there can not be exactly matched,So I use round() function to
match .1th.
[pre]
%let mu=5; *Normal Distribution 's position parameter;
%let sigma=1.2; *Normal Distribution 's scale parameter;
%let mean=5.0; * Your arithmetic Mean;
%let sample_size=500;
%macro normal(mu= , sigma= , sample_size= , mean=);
data normal_&sample_size ;
value=rand('normal',μ,σ); count+1; sum+value;
output;
do until(count = &sample_size);
value=rand('normal',μ,σ);count+1; sum+value;
if round(sum/count,.1) = &mean then output;
else do;
count+(-1);
sum+(-1)*value;
end;
end;
run;
%mend;
%normal(mu=μ,sigma=σ,sample_size=&sample_size,mean=&mean)
[/pre]
Ksharp