Turn on suggestions

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

Showing results for

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-14-2012 12:22 PM
(1420 views)

Hello,

I'm simulating a variable say X that follows a normal standard distribution with the rannor() function.

With n=5000, the mean of X is far from 0 and out of the prediction interval.

With 100 000 000 generated variables, the mean is near 0 but we cannot simulate such a number of variables for the rest of our work.

With R, the same simulation produces a variable with a mean less than 1.10-4 in absolute value and this with only 500 generated variables.

The same problem occurs with the normal() function.

I use SAS 9.2 with Windows 7 X64.

Do you encounter the same problem ? Is it due to SAS ?

Here is my code :

data test;

do i=1 to 10000;

Y1=rannor(-1);

Y2=normal(-1);

output;

end;

run;

proc means data=test;

var Y1 Y2;

run;

4 REPLIES 4

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Not particularly helpful, but you can see this thread with some discussion around random numbers in SAS though they're discussing the uniform distribution instead.

http://listserv.uga.edu/cgi-bin/wa?A2=ind1204c&L=sas-l&D=0&P=19477

You can also try the rand('normal', 0, 1) function.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I get no sign of non-normality with this :

data test;

do i=1 to 10000;

Y1=rannor(-1);

Y2=normal(-1);

Y3=rand("NORMAL");

output;

end;

run;

proc univariate data=test normal;

var Y1 Y2 Y3;

run;

I'm using SAS 9.3 on Windows 7, 32 bits.

PG

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

If I recall correctly both of these random functions will use the same random number stream. Use the CALL versions to have a different stream for each function.

This may be causing your problem.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

A few comments:

1) RANNOR and NORMAL are the same function. NORMAL is just an alias to RANNOR.

2) A 95% confidence interval means that in 95% of random samples, the sample mean will be within the computed CI. In terns of "seeds," this means that 95% of seeds will give a sample mean within the CI. So any single sample doesn't tell us anything. You might be "unlucky" and choose that one-in-twenty seed!

3) I am running on Windows 7 and X64 and I do not see the situation you report. Use the CLM option on the PROC MEANS statement to get PROC MEANS to display the confidence limits:

proc means data=test N mean clm;

var Y1 Y2;

run;

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

**If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. **

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.