In this example, you write a program to create a scatter plot and a histogram from variables in a DataObject. Type or copy the following statements into a program window, and select Program Run from the main menu.
declare DataObject dobj; dobj = DataObject.CreateFromFile("Hurricanes"); declare ScatterPlot plot; plot = ScatterPlot.Create( dobj, "min_pressure", "wind_kts" ); declare Histogram hist; hist = Histogram.Create( dobj, "latitude" ); hist.SetWindowPosition( 50, 50, 50, 50 );
The first set of statements create a DataObject and are explained in Chapter 2, Reading and Writing Data. The next statements declare plot to be an IMLPlus variable that refers to a ScatterPlot, which is the class that displays and manipulates attributes of a scatter plot. The scatter plot in this example is created from the min_pressure and wind_kts variables in the DataObject. The min_pressure variable contains the minimum central pressure in hectopascals (1 hPa = 1 millibar), and the wind_kts variable contains the maximum wind speed in knots for each observation of a tropical cyclone.
The final set of statements declare hist to be a Histogram, which is the class that displays and manipulates attributes of a histogram. The histogram is created from the latitude variable. The latitude variable contains the latitude in degree (north of the equator) at which the observation was made.
To avoid having the histogram appear on top of the scatter plot, the SetWindowPosition method is called to move the histogram into the lower right corner of the SAS/IML Studio workspace. The SetWindowPosition method is a method in the DataView class. Any plot or data table can call methods in the DataView class. (Formally, the DataView class is a base class for all plots and data tables.) The DataView class is documented in the SAS/IML Studio online Help.