BookmarkSubscribeRSS Feed
karen8169
Obsidian | Level 7

When I try to rewrite the orginal code to fit my data, it always appears that "ERROR: (execution) Matrix has not been set to a value.".
But I don't know where can I correct them. By the way, I want to know how to store het_y into a column form.

Thanks a million.

 

proc IML;
use work.jb_test_data;
read point (1:252) var{BIDLO ASKHI PRC VOL RET} into m;

n=nrow(m); r=ncol(m);
y=m[,5]; x=shape(1,n,1)||m[ ,1:2:3:4];

beta=inv(t(x)*x)*t(x)*y;
sigma=sqrt(t(y-x*beta)*(y-x*beta)/(n-r));
se=sigma*sqrt(vecdiag(inv(t(x)*x)));
het_y=x*beta;
print het_y;



2 REPLIES 2
ballardw
Super User

It often helps to post the entire log of the code and any error /warning messages to diagnose things.

Also, since you use the phrase "try to rewrite the orginal code to fit my data" it appears that you are following another code file.

It may help to post that original code as well.

Rick_SAS
SAS Super FREQ

The index creation operator (:)  has the syntax initial:final.  In your case, the correct syntax is

x=shape(1,n,1) || m[ ,1:4];

 

See the "Tutorial" section of the SAS/IML documentation for other tips for using SAS/IML for linear regression.

 

To write vectors to a SAS data set, see "Writing data from a matrix to a SAS data set."

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 776 views
  • 1 like
  • 3 in conversation