turn on suggestions

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 Studio
- /
- Issue with Random Number Generation

Topic Options

- 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

09-08-2016 08:41 PM

I am trying to solve this issue and I am very new to sas. Can someone please help me?

Simulate 200 observations from the following linear model: Y = alpha + beta1 * X1 + beta2 * X2 + noise

where

• alpha=1, beta1=2, beta2=-1.5

• X1 ~ N(1, 4), X2 ~ N(3,1), noise ~ N(0,1)

I have this so far but do not think its right.

DATA ONE;

alpha = 1;

beta1 = 2;

beta2 = -1.5;

RUN;

DATA CALC;

SET ONE;

DO i = 1 to 200;

Y=alpha+beta1*X1+beta2*X2+Noise;

X1=Rannor(1);

X2=rannor(3);

Noise=ranuni(0);

OUTPUT;

END;

RUN;

PROC PRINT DATA=CALC;

RUN;

Accepted Solutions

Solution

09-09-2016
10:40 PM

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

09-09-2016 01:07 AM

All Replies

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

09-08-2016 09:18 PM

Yeah, I don't think so either. Hopefully this helps provide you with some more direction:

X1 ~ N(1, 4) -> X is Normally distributed with a mean of 1 and standard deviation of 4.

RANNOR (Seed)

The RANNOR function returns a variate that is generated from a normal distribution with. The Box-Muller transformation of RANUNI uniform variates is used.mean 0 and variance 1

Reading further into the documentation:

x=MU+sqrt(S2)*rannor(seed);

Your order is also incorrect. You need to create the random variables X1/X2/Noise __before__ you apply the formula.

Solution

09-09-2016
10:40 PM

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

09-09-2016 01:07 AM