SAS Examples

Instructor:  Joshua D. Naranjo
E-mail: joshua.naranjo@wmich.edu
Phone: (269)387-4548
Office: 5507 Everett Tower
Some basic rules in writing SAS programs

  1. Notice that the example below satisfies the following basic rules
    • Every statement ends in a semicolon
    • Data lines DO NOT end in a semicolon (a line of data is not considered a statement)
    • Words in SAS statements are not case sensitive. I use capitalization below only to distinguish between SAS keywords ('DATA' and 'INPUT') and user selected names ('homes' and 'price').
    • It is good style to use indentation and blank lines to distinguish between the start of a DATA step (or PROC step) and the rest of the statements in that step.
  2. Example
                   
              DATA homes;                              
                     INPUT price sqft age;             
                     priceT=price/1000;                
                     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;                  
              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