Examples of SAS code and SAS usage (by Harry Joe)

SAS usage (by Harry Joe)

SAS examples

Note that SAS/IML can be used in "interactive mode" (but not as nice a Splus/R), with

      sas -nodms

from the Unix command line. Then type 'proc iml' and create variables, vectors or matrices. Type 'endsas' to end your interactive SAS session. Alternatively submit IML statements from the SAS program window, and look for the output in the SAS output window (error messages in SAS LOG window).

 

SAS Insight for interactive data analysis

Step 1: convert an ascii/text file to SAS binary format (extension is .ssd or .ssd01 in Unix).

libname tem '/home/faculty/hjoe/s445';

data tem.iris;
   infile 'iris.dat' firstobs=2; /* first line consists of variable names */
   /* the default field delimiter is one or more spaces */
   /* there are special data formats in SAS */
   input sepallen sepalwid petallen petalwid species $;
run;

The result in /home/faculty/hjoe/s445 is

  -rw-r--r--   1 hjoe     faculty    16384 Dec 10 14:35 iris.ssd01

Step 2. Starting SAS/Insight. By default, SAS/Insight will only find .ssd01 files if they are in your ~/sasuser directory. If your .ssd01 files are elsewhere, do something like below with the PROC INSIGHT.

libname s545 '/home/faculty/hjoe/s545';
 
proc insight data=s545.aes;
  run;

These 4 lines can be in a SAS file, eg. startida.sas, and started with the Unix command

      sas startida.sas

or they can be typed in the SAS Editor Window and submitted.

 

SAS Toolbar

To assess your SAS data (.ssd) files interactively from menus and SAS INSIGHT, SAS FSVIEW, SAS FSEDIT, SAS FSBROWSE etc., add the path/directory names using 'libname' in your '~/autoexec.sas' file. For example, if /home/faculty/hjoe/s445 contains

    iris.ssd01 

and /home/faculty/hjoe/sasdata contains

    customer.ssd01 employee.ssd01 invoice.ssd01 product.ssd01   

then put the following into autoexec.sas (in your home directory)

     libname s445 '/home/faculty/hjoe/s445';
     libname sasdata '/home/faculty/hjoe/sasdata';

By default, SAS starts with

     libname sasuse '~/sasuser';

A number of menus from a spreadsheet/database view can be accessed from the toolbar. For example,

  • If you have a directory ~/sasuser in your home directory with a SAS file houses.ssd01, then typing

        fsview sasuser.houses
    

    will bring up data set with menus, from which some SQL can be done from the Search menu. Similarly,

        fsview sasdata.customer
    

    will open sasdata/customer.ssd01. For string variables, you can type 'Where' strings such as

          empname like 'S%'
    

    or

          empname like '___k'
    

    For SQL mistakes, note the "Undo last where" option in the Search menu.

     

  • Typing

        fsedit sasdata.customer
    

    allows you to edit your SAS data set and re-save. Note that the data comes up in a form with a line for each variable.

  • Typing

        fsbrowse sasdata.customer
    

    leads to the same format of the data set as 'fsedit' but no editing can be done.

     

  • Typing

        insight 
    

    will bring up a menu of your libname's from which you can choose your data set, or if you want to bring up a specific data, type something like

        insight data=s445.iris
    

     

  • You can also bring up s445.iris by going to the Program Editor Window, choose the Globals menu, then Analyze, then Interactive Data Analysis. Then choose s445 as the library (from left panel) and the data set from the right panel, and click the Open button.

Forecast

Why do the smoothing forecasts generated by the Time Series Forecasting System differ from those generated by PROC FORECAST?

The specific methods used in the two approaches differ in two ways. First of all, the Time Series Forecasting System optimizes the smoothing weights for a particular time series while the default smoothing values of PROC FORECAST are constants that do not depend on the data series. (With PROC FORECAST, the user may specify the weights explicitly, overriding the default weights of PROC FORECAST.) Secondly, the Time Series Forecasting System uses a smoothing state initialization different than that of PROC FORECAST. For further details, see pages 225-235 of the SAS/ETS Software: Time Series Forecasting System, Version 6, First Edition and pages 443-450 of the SAS/ETS User's Guide, Version 6, Second Edition. This information is also found in the Version 7 SAS OnlineDoc.

 

 

FAQ Category