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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;
...

 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

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;
...

 

PaigeMiller
Diamond | Level 26

I think you need parentheses and not curly brackets.

 

read ALL var ("var1":"var1000") into x;
--
Paige Miller
Ksharp
Super User

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 ;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 985 views
  • 0 likes
  • 4 in conversation