I'm using SAS 9.4.
I'm new to IML and a little unfamiliar. I have a code that works, however, I am trying to create an X matrix with over 1000 variables (all named the same thing with corresponding numbers at the end). I can't figure out how to enter this in proc iml, as I tried var1-var1000 and var1:var1000 and proc iml does not like the hyphen or colon. Here is my code:
proc iml;
use dataset;
read ALL var {var1-var1000} into x;
read all var {yvar} into y;
close dataset;
xBar = mean(x); /* save row vector of means */
yBar = mean(y); /* save mean of Y */
x = x - xBar; /* center X and y; do not add intercept */
y = y - yBar;
.
.
.
The rest of the code is irrelevant to my question.
If I run the code with just a few x variables and state:
read ALL var {var1 var2 var3} into x;
Then my code runs fine. However, I can't type over 1000 variables. How can I include ALL variables at once into this matrix X?
Why not use the variable list with KEEP= option when telling IML what dataset to use?
proc iml;
use dataset(keep=var1-var1000);
read ALL into x;
close dataset;
...
Why not use the variable list with KEEP= option when telling IML what dataset to use?
proc iml;
use dataset(keep=var1-var1000);
read ALL into x;
close dataset;
...
I think you need parentheses and not curly brackets.
read ALL var ("var1":"var1000") into x;
Tom has already give you answer .
And why not post it at IML forum ,since it is a IML question.
proc iml;
use dataset(keep=var1-var10000) ;
read ALL var _all_ into x;
close;
use dataset(keep=yvar);
read all var {yvar} into y;
close ;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.