BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I'm trying to run a LMS regression in SAS/IML, and can successfully get it to run, but I am having trouble controlling the output. I have 15 independent variables and need the output labeled, but it comes out as var1, var2, etc.

Here is what I have:

proc iml ;
use WORK.auto;
read all var {&input &model1} into model1;
title "MODEL 1";
title2 "5% CENTRALITY BY VALUE";
a = model1[1:59,2:16];
b = model1[1:59,1];

optn = j(8,1,.);
optn[2]= 1;
optn[3]= 1;
optn[8]= 1;
call lms(sc,coef,wgt,optn,b,a);
close work.auto;
quit;

If anyone knows how to get the parameter estimates etc in the output to have the variable names, please let me know.

Thanks!
2 REPLIES 2
Rick_SAS
SAS Super FREQ
The variable names in the ODS tables are obviously being hard-coded as VAR1-VAR16, and I don't think you can change that portion of the output. The problem, of course, is that the LMS routine takes a matrix of explanatory variable (your 'a' matrix), so it actually doesn't know the names of the data set variables from which the matrix was created.

It would be a good idea to extend the LMS routine to provide the functionality you want.

You can, however, use ODS output to save the tables to a data set and then use the DATA step or PROC IML to rename the variables. If you are interested in that, here is some sample code:

%let input = MPG_Highway;
%let model1 = EngineSize Horsepower Weight Length;

proc iml ;
use Sashelp.cars; /* you'll have this if you have SAS/GRAPH */
read all var {&input &model1} into model1;
close Sashelp.cars;

a = model1[,2:ncol(model1)];
b = model1[,1];
optn = j(8,1,.);
optn[2]= 1; optn[3]= 1; optn[8]= 1;

*ods trace on / listing;
ods output EstCoeff=ParamEst; /* write one or more tables to data sets */
call lms(sc,coef,wgt,optn,b,a);
ods output close;

/* read data with names 'VAR1':'VARn' and 'Intercep' */
use ParamEst;
read all var _NUM_ into x[colname=oldVarNames];
close ParamEst;

/* rewrite data with new names */
varNames = {&model1} || "Intercep";
create ParamEst from x[colname=varNames];
append from x;
close ParamEst;
quit;

proc print data=ParamEst;
run;
deleted_user
Not applicable
Thanks!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 1233 views
  • 0 likes
  • 2 in conversation