1
votes

I'm pretty new in proc iml. sooo......I can not declare and create a variable.In the coding line, declare showing in red. If I run it, it is like ' Statement is not valid or it is used out of proper order'

Thank you for your help

    proc iml;
declare DataObject dobj;
   dobj = DataObject.CreateFromFile("Hurricanes");
   dobj.Sort( "latitude" );
2
I've rolled back to the original question. If you want to ask a different question (ie, how do I create a histogram in Base SAS/Proc IML), please ask as a different question.Joe

2 Answers

2
votes

That is IML Studio syntax, not a PROC IML syntax. IML Studio uses IMLPlus, which is an object oriented version of IML, basically. See this documentation page for more information.

2
votes

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.