BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
2 REPLIES 2
Patrick
Opal | Level 21
post deleted

Message was edited by: Patrick
Paige
Quartz | Level 8
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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 535 views
  • 0 likes
  • 3 in conversation