SAS Examples

Instructor:  Joshua D. Naranjo
E-mail: joshua.naranjo@wmich.edu
Phone: (269)387-4548
Office: 5507 Everett Tower
Using Comments, Titles, and Options

  1. Comments

    Comments between slash-star and star-slash are ignored (see example below). Comments help you remember, and make your code more readable for others.

  2. Options

    Options are commands that create settings for the whole session. They appear outside DATA and PROC steps.

  3. Titles

    TITLE statements create headers for each page of output. TITLEx creates a header line on the xth line of each page.

  4. Example
                   
    
         /* This SAS code illustrates the use of comments, options, */
         /*   and titles.                                           */
    
         DM "OUT;CLEAR;LOG;CLEAR;";   /* Clear OUTPUT and LOG windows  */
                                      /* By default, SAS appends new   */
                                      /*  output to old output. This   */
                                      /*  makes it replace old output. */
         OPTIONS LS=80 PS=60 NODATE;  /* Set line size and page size   */
                                      /*  to print in portrait format. */
                                      /*  Don't print time and date.   */
    
         DATA homes;                              
                INPUT price sqft age;             
                priceT=price/1000;       /* Rescale home price */
                DATALINES;
         205000 2650 13
         215000 2664  6
         215000 2921  3
         199900 2580  4
         190000 2580  4
         180000 2774  2
         156000 1920  1
         137500 1837  4
         127000 1880  8
         125000 2150 15
         123500 1894 14
         117000 1928 18
         ;                                        
    
         PROC PRINT DATA=homes;                  
                TITLE "Data on Home Prices";
                TITLE2 "(Stat 6620: Applied Linear Models)";
         RUN;                                   
    
         PROC PRINT DATA=homes;                  
                VAR priceT sqft age;
                TITLE2 "(Price in thousand dollars, square feet, and age) ";
         RUN;                                   
    
         QUIT;
    

 

Department of Statistics
3304 Everett Tower
Western Michigan University
Kalamazoo MI 49008-5152 USA
(269) 387-1420 | (269) 387-1419 Fax
stat-webmaster@wmich.edu