1

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" );
Joe
  • 62,789
  • 6
  • 49
  • 67
  • 1
    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](http://meta.stackexchange.com/questions/43478/exit-strategies-for-chameleon-questions "at Stack Exchange sites, “chameleon questions” are not quite welcome")**. – Joe Jan 30 '15 at 21:59

2 Answers2

2

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.

Joe
  • 62,789
  • 6
  • 49
  • 67
  • 1
    Interesting stuff, I had assumed that IML Studio was a UI wrapping IML functionality. I hope I get a chance to play with it at some point. – SRSwift Jan 30 '15 at 18:15
2

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.

SRSwift
  • 1,700
  • 9
  • 11
  • tnx!! I think the issue maybe I run under regular sas...I'm trying to do a bootstrap/permutation paired t test with resampling. The 'declare' part occurs in the tutorial when trying to draw a histogram.. – shakedong93 Jan 30 '15 at 18:46
  • BTW....does that mean I can not graphic anything in regular SAS in the proc iml?(sas9.4) – shakedong93 Jan 30 '15 at 19:16
  • You can create plots. but not using IML Studio methods (your declare statement onwards). Look instead at `proc sgplot`. Additionally, please make sure that your question still matches the post title and replies; otherwise it can be difficult for other users to understand why answers don't match the question. If you wish to add more put it at the bottom of the question, or explain the edits. – SRSwift Jan 30 '15 at 20:24
  • Thank you Swift. I appreciate that – shakedong93 Jan 30 '15 at 20:49
  • 1
    PROC IML also has a number of calls that create ODS graphics: http://blogs.sas.com/content/iml/2014/06/30/standard-statistical-graphs/ – Rick Jan 31 '15 at 12:43
  • Interesting, I'd not come across this before. Thanks, and thanks also for the tip sheet. – SRSwift Jan 31 '15 at 18:00