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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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