If you want to read a dataset into an IML matrix via code the usual method is:
proc iml;
use sashelp.class; /* Open the dataset for reading */
read all var _num_ into A; /* Put all the rows and all numeric columns into a matrix called A*/
close sashelp.class; /* Close the dataset */
/* Your IML statements here */
print A;
quit;
I've never seen the declare or dataobject syntax before so perhaps someone else can explain that. I think it might be specific to SAS/IML Studio rather than SAS/IML. [edit] See Joe's answer for an explanation.
A great reference for IML code can be found here. Further details on the read statement (how to specify which variables and rows to read) can be found here.
Edit to answer extended question
You can export your data from IML to a dataset using the create
and append
statements. Then use other procedures to perform your graphing proc univariate
or proc sgplot
for histograms.
proc iml;
/* Read in your Data */
use sashelp.cars;
read all var _num_ into A;
close sashelp.cars;
/* Your IML statements here */
B = A;
/* Write out your data */
create temp from B;
append from B;
quit;
/* Plot a histogram of the first two columns */
proc sgplot data = temp;
histogram col1 / binstart = 0 binwidth = 10000;
histogram col2 / binstart = 0 binwidth = 10000 transparency= 0.5;
run;
When you are looking at the documentation you should avoid the IML Studio user guide as you don't have access to that product. Instead try to Base SAS, STAT and IML.