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

I have a data set with a number of columns. I am wanting to create a data set from this using a selection of the columns:

 

In iml

 

Instead of

use = old_use[1:100, 1:75];

 

I want to have

use = old_use[1:100, 1:50] + old_use[1:100, 53:57] + old_use[1:100, 59:75];

 

But it is not returning the correct number of columns....

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

The addition operator is trying to add matrices that do not have the same number of columns. Perhaps you mean to use the concatenation operator:

 

use = old_use[1:100, 1:50] || old_use[1:100, 53:57] || old_use[1:100, 59:75];

 

If so, a more efficient method is to form a vector of the column indices and then do a single extraction:

 

cols = (1:50) || (53:57) || (59:75);

use = old_use[1:100, cols];

View solution in original post

4 REPLIES 4
Rick_SAS
SAS Super FREQ

The addition operator is trying to add matrices that do not have the same number of columns. Perhaps you mean to use the concatenation operator:

 

use = old_use[1:100, 1:50] || old_use[1:100, 53:57] || old_use[1:100, 59:75];

 

If so, a more efficient method is to form a vector of the column indices and then do a single extraction:

 

cols = (1:50) || (53:57) || (59:75);

use = old_use[1:100, cols];

newSAS2017
Calcite | Level 5

Thank you that works really well!

 

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 4 replies
  • 861 views
  • 0 likes
  • 3 in conversation