Statistical programming, matrix languages, and more

Proc IML Exercise

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Proc IML Exercise

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.

Accepted Solutions
Solution
‎08-08-2016 11:12 AM
Grand Advisor
Posts: 9,596

Re: Proc IML Exercise

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


All Replies
Solution
‎08-08-2016 11:12 AM
Grand Advisor
Posts: 9,596

Re: Proc IML Exercise

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;

Occasional Contributor
Posts: 5

Re: Proc IML Exercise

Thanks, this works now!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 274 views
  • 0 likes
  • 2 in conversation