BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sykim
Calcite | Level 5
I am trying to do matrix operations on SAS using a dataset I call 'ao' which has 7 variables and which I have attached. As an experiment, I am doing a scalar operation on the data I read in as a matrix, and I want to output it back out as a sas dataset using the following code:


proc iml;
use aoy;
read all var _ALL_ into Gamma[colname=varNames];
y=2*Gamma;
close ao;
create test from y[colname={"ind2" "MRP" "SMB" "HML" "RMW" "CMA" "RF"}];;
append from test;
close test;
quit;

For some reason SAS gives me the error message:"Number of columns in test does not match with the number of variables in the data set". I don't see how this is posssible because the dataset has exactly 7 variables. Please let me know if there is anything wrong with the code. I have attached the dataset for convenience.
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Your code is not right.


proc import datafile='/folders/myfolders/aoy.xlsx' out=aoy dbms=xlsx replace;run;
proc iml;
use aoy;
read all var _ALL_ into Gamma[c=vnames];
close;
y=2#Gamma;
create test from y[colname=vnames];
append from y;
close test;
quit;

View solution in original post

2 REPLIES 2
Ksharp
Super User
Your code is not right.


proc import datafile='/folders/myfolders/aoy.xlsx' out=aoy dbms=xlsx replace;run;
proc iml;
use aoy;
read all var _ALL_ into Gamma[c=vnames];
close;
y=2#Gamma;
create test from y[colname=vnames];
append from y;
close test;
quit;

sykim
Calcite | Level 5

Thanks, this works now!

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
  • 1509 views
  • 0 likes
  • 2 in conversation