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 04-22-2017 08:24 PM
(1679 views)

Dear All,

I was trying to run this and I got this for the 3 matrices created "(Execution) Matrices has not been set a value";

proc iml;

*part a;

n = 10;

x1 = j(10,1,1);

x2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

x = x1 || x2;

M = 1000;

B10 = j(M,1,0);

T10 = j(M,1,0);

title "Answer to part a";

print x1 x2 x M B10 T10;

*part b;

u = j(n,1,0);

Btot = {1, 2};

Var = {2};

*part c;

do i = 1 to M;

call randgen(u,"normal",0,Var);

y = (x*BTot) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B10[i,] = b2;

B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = s2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T10[i,] = t2;

end;

*part d;

n = 100;

x_1 = j(100,1,1);

x_2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 10);

x = x_1 || x_2;

M = 1000;

B100 = j(M,1,0);

T100 = j(M,1,0);

u = j(n,1,0);

Btot = {1, 2};

S = {2};

do i = 1 to M;

call randgen(u,"normal",0,S);

y = (x*B_pop) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B100[i,] = b2;

B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = se2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T100[i,] = t2;

end;

*part e;

n = 1000;

x1 = j(1000,1,1);

x2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 100);

x = x1 || x2;

M = 1000;

B1000 = j(M,1,0);

T1000 = j(M,1,0);

u = j(n,1,0);

Btot = {1, 2};

Var = {2};

do i = 1 to M;

call randgen(u,"normal",0,S);

y = (x*Btot) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B1000[i,] = b2;

B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = se2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T1000[i,] = t_2;

end;

9 REPLIES 9

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

Can you narrow it down to which part of your code is generating the error? And including the log is helpful as well.

@Mike7 wrote:

Dear All,

I was trying to run this and I got this for the 3 matrices created "(Execution) Matrices has not been set a value";

proc iml;

*part a;

n = 10;

x1 = j(10,1,1);

x2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

x = x1 || x2;

M = 1000;

B10 = j(M,1,0);

T10 = j(M,1,0);

title "Answer to part a";

print x1 x2 x M B10 T10;*part b;

u = j(n,1,0);

Btot = {1, 2};

Var = {2};*part c;

do i = 1 to M;

call randgen(u,"normal",0,Var);

y = (x*BTot) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B10[i,] = b2;B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = s2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T10[i,] = t2;

end;*part d;

n = 100;

x_1 = j(100,1,1);

x_2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 10);

x = x_1 || x_2;

M = 1000;

B100 = j(M,1,0);

T100 = j(M,1,0);

u = j(n,1,0);

Btot = {1, 2};

S = {2};do i = 1 to M;

call randgen(u,"normal",0,S);

y = (x*B_pop) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B100[i,] = b2;B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = se2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T100[i,] = t2;

end;*part e;

n = 1000;

x1 = j(1000,1,1);

x2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 100);

x = x1 || x2;

M = 1000;

B1000 = j(M,1,0);

T1000 = j(M,1,0);

u = j(n,1,0);

Btot = {1, 2};

Var = {2};do i = 1 to M;

call randgen(u,"normal",0,S);

y = (x*Btot) + u;

b = inv((x`) * x) * (x`) * y;

e = y - (x*b);

b2 = b[2,1];

B1000[i,] = b2;B2 = Btot[2,1];

se2 = ((e`) * e) * (1/(n - 2));

varb2 = se2 * b2;

seb2 = sqrt(varb2);

t2 = (b2 - B2) * (1/seb2);

T1000[i,] = t_2;

end;

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

its generating errors in the three parts, when trying to create T10, T100, and T1000

Its telling me that the matric has not been set a value; however I tried setting a value in the beginning but did not work

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

That's not what it's saying. Read the error thoroughly and fix what it indicates is the error.

FYI it's a typo.

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

I fixed the Typo, but still getting errors for T10 T100 T1000

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

Out of curiosity how am I supposed to have any idea of either what the error or your code looks like now?

Post your modified code AND log with errors.

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

i fixed the typo but i am having problems with another error

(execution) Invalid subscript or subscript out of range

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

```
83 varb2 = s2 * b2;
84 seb2 = sqrt(varb2);
85 t2 = (b2 - B2) * (1/seb2);
86 T10[i,] = t2;
87 end;
ERROR: (execution) Matrix has not been set to a value.
operation : * at line 83 column 12
operands : s2, b2
s2 0 row 0 col (type ?, size 0)
```

According to LOG, it said you did not define s2 before . I think s2 should be se2 ?

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

Also you do not define B_pop ,are supposed to be Btot

t_2 is supposed to be t2?

```
proc iml;
*part a;
n = 10;
x1 = j(10,1,1);
x2 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
x = x1 || x2;
M = 1000;
B10 = j(M,1,0);
T10 = j(M,1,0);
title "Answer to part a";
print x1 x2 x M B10 T10;
*part b;
u = j(n,1,0);
Btot = {1, 2};
Var = {2};
*part c;
do i = 1 to M;
call randgen(u,"normal",0,Var);
y = (x*BTot) + u;
b = inv((x`) * x) * (x`) * y;
e = y - (x*b);
b2 = b[2,1];
B10[i,] = b2;
B2 = Btot[2,1];
se2 = ((e`) * e) * (1/(n - 2));
varb2 = se2 * b2;
seb2 = sqrt(varb2);
t2 = (b2 - B2) * (1/seb2);
T10[i,] = t2;
end;
*part d;
n = 100;
x_1 = j(100,1,1);
x_2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 10);
x = x_1 || x_2;
M = 1000;
B100 = j(M,1,0);
T100 = j(M,1,0);
u = j(n,1,0);
Btot = {1, 2};
S = {2};
do i = 1 to M;
call randgen(u,"normal",0,S);
y = (x*Btot) + u;
b = inv((x`) * x) * (x`) * y;
e = y - (x*b);
b2 = b[2,1];
B100[i,] = b2;
B2 = Btot[2,1];
se2 = ((e`) * e) * (1/(n - 2));
varb2 = se2 * b2;
seb2 = sqrt(varb2);
t2 = (b2 - B2) * (1/seb2);
T100[i,] = t2;
end;
*part e;
n = 1000;
x1 = j(1000,1,1);
x2 = repeat({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, 100);
x = x1 || x2;
M = 1000;
B1000 = j(M,1,0);
T1000 = j(M,1,0);
u = j(n,1,0);
Btot = {1, 2};
Var = {2};
do i = 1 to M;
call randgen(u,"normal",0,S);
y = (x*Btot) + u;
b = inv((x`) * x) * (x`) * y;
e = y - (x*b);
b2 = b[2,1];
B1000[i,] = b2;
B2 = Btot[2,1];
se2 = ((e`) * e) * (1/(n - 2));
varb2 = se2 * b2;
seb2 = sqrt(varb2);
t2 = (b2 - B2) * (1/seb2);
T1000[i,] = t2;
end;
quit;
```

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

@Ksharp and here I was trying to let 'Mike' do his own homework 😉

Are you ready for the spotlight? We're accepting content ideas for **SAS Innovate 2025** to be held May 6-9 in Orlando, FL. The call is **open **until September 16. Read more here about **why** you should contribute and **what is in it** for you!

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.