Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Need Help finding mean of random numbers

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-21-2009 05:29 PM

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!

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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-21-2009 07:38 PM

post deleted

Message was edited by: Patrick

Message was edited by: Patrick

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

10-22-2009 11:36 AM

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.

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.