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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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