BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ardoshi
Calcite | Level 5

I have the following code:

proc iml;

     use prepped;

     read all;

     hstar = j(200000,1,.);

     do i = 1 to 2;

          do j = 1 to 6;

               hstar[100000*(i-1)+j] = hhat;

          end;

     end;

quit;

The line that reads

hstar[100000*(i-1)+j] = hhat;

gives the following error:

ERROR: (execution) Matrices do not conform to the operation.

operation : [ at line 124 column 9

operands: HSTAR, _TEM1003, HHAT

HSTAR 200000 rows    1 col       (numeric)

_TEM1003 1 row          1 col       (numeric)

HHAT 200000 rows       1 col       (numeric)

statement: ASSIGN at line 124 column 4

Can anybody help with this?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

For each value of i and j,  hstar[100000*(i-1)+j] is a scalarl value.

However, hhat is a vector with 200,000 rows. You can't assign a vector to a scalar.

If you describe what you're trying to achieve, someone could help further.

View solution in original post

2 REPLIES 2
Rick_SAS
SAS Super FREQ

For each value of i and j,  hstar[100000*(i-1)+j] is a scalarl value.

However, hhat is a vector with 200,000 rows. You can't assign a vector to a scalar.

If you describe what you're trying to achieve, someone could help further.

ardoshi
Calcite | Level 5

Thanks!

What I needed to do was

hstar[100000*(i-1)+j] = hhat[100000*(i-1)+j];

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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. 

Register now!

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.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 2 replies
  • 973 views
  • 0 likes
  • 2 in conversation