Help using Base SAS procedures

Need Help finding mean of random numbers

Reply
N/A
Posts: 0

Need Help finding mean of random numbers

Hi,
I have generated 100 samples each with 100 random numbers between 0 and 1 using the following code (thnx patrick!):

data RandomNumbers;
do sample=1 to 100;
do n=1 to 1000;
RandomNumber=ranuni(0);
output;
end;
end;
run;

For each of these samples I found the mean using proc tabulate. Now, I need to find the (simulated) probability that the mean of a sample is between .49 and .5, inclusive.
Any ideas?

Is there a way to get the proc tabulate output into a dataset so I can then use "if" statements to keep all means between .49 and .5, count them and then divide by 100 to get the probability? Or is there a faster way to do this entirely in the data step (ie. using another loop)?
Thanks, your help would be much appreciated!
Respected Advisor
Posts: 3,887

Re: Need Help finding mean of random numbers

post deleted

Message was edited by: Patrick
Super Contributor
Posts: 281

Re: Need Help finding mean of random numbers

One solution:

PROC MEANS, BY SAMPLE with an OUTPUT statement, puts all your means into a dataset. Then, use another data step to count the times the mean is in the desired range, and the number of times it is not in the desired range.
Ask a Question
Discussion stats
  • 2 replies
  • 88 views
  • 0 likes
  • 3 in conversation