Q:

How to initialize a simple matrix in SAS?

I am new to SAS and have been using R most of the time. I am stuck with a simple and frustrating issue. All I want to do is to create a simple 3 X 3 matrix in SAS. But it throws an error. I need some help in understanding what's going on. The SAS documentation is not very helpful.
data matrixTest;
 input Y $ X;
 cards;
 4 0
 3 1
 1 1
 ;
run;

/*Convert X to a categorical variable*/
data matrixTest;
set matrixTest;
if X = 0 then X = "0";
else X = "1";
run;

/*Get design matrix from the regression model*/
 proc transreg data=matrixTest design;
  model class(X/ zero=last);
  output out=input_mcmc(drop=_: Int:);
 run;

mX = {5 4 3, 4 0 4, 7 10 3};

And I get the following error when creating the matrix mX:
ERROR 180-322: Statement is not valid or it is used out of proper order.

A:

Your error is that SAS is not a matrix language.  SAS is more like a database language; the unit of operation is the dataset, analogous to a SQL table or a dataframe in R or Python.
SAS does have a matrix language built into the system, SAS/IML (interactive matrix language), but it's not part of base SAS and isn't really what you use in the context you're showing.  The way you enter data as part of your program is how you did it in the first data step, with datalines.  
Side note: You're also showing some R tendencies in the second data step; you cannot convert a variable's type that way.  SAS has only 'numeric' and 'character', so you don't have 'categorical' data type anyway; just leave it as is.

