The MCHP SAS MANUAL - Create Height/Weight/Region - program


Home    Contents

Windows in SAS
File management

The SAS Program
Program syntax
Debugging tips

1. Prepare the data set 
   Types of data 
   Example programs    
2. View the data
   SAS Procedures
3. Explore the data  
   Numeric statistics    
   Frequency tables    
4. Manipulate the data  
   Basic techniques    
   New variables
5. Adding Variables and 
Observations to Data Sets
   The SET Statement
   The MERGE Statement

6. Data Processing
   ARRAY Statement
   Do Loops
   By-Group Processing
   RETAIN Statement

 Simulated clinical data 
 Simulated Manitoba Health 

Sample Data Sets: Height/Weight/Region - Program

This program can be used to create a temporary SAS data set called "htwt_reg" from scratch. Nothing else is needed to produce this data set. This data set will be available at any time during the SAS session. For subsequent sessions, the saved program can be run again to re-create the "htwt_reg" data set.
  1. Enter the following program directly into the SAS Program Editor window (the comments do not need to be entered).
  2. Save the program (e.g.,
  3. Submit the program for processing.
  4. Check both log and output windows to ensure the program ran accurately
  5. Debug the program, if necessary; save it again, and submit it again (clearing the log and output windows first so that only the most recently-submitted versions will appear).
It is important to line up the values for the 18 observations exactly as specified in the INPUT statement. The INPUT statement indicates that values for NAME, for example, can take up to 10 spaces, beginning at column 1, and that the values should be read in as character ($). There are 3 spaces, from column 11-13, and then REGION (also read in as character and can take up 12 spaces) is entered at column 14 (or the 14th space over from the beginning of the line). It must be entered at this 14th space if SAS is to pick up the values of REGION for each observation. The values for each observation should thus be lined up, in columns, as specified in the INPUT statement (the space bar can be used to count over to the appropriate column, or space, on the screen).
* Example 3 - only for creating *
* htwt_reg data used *
* *
* *
* This program creates a temporary *
* SAS data set used in in the example 3 *
* program. In most cases this data set *
* will be available as a permanent SAS *
* file in the course library *
****************************************** ;
data htwt_reg                ; 
               ** informats are similar to usign an informat on 
               an input statement to define the lenght of 
               a variable. This method is often used 
               when reading variable length fields from 
               list or delimited input files. ; 
informat name $10. region $12. ; 
input @1 name @14 region ; 
cards ; 
Aubrey       Winnipeg 
Ron          Winnipeg 
Carl         Winnipeg 
Antonio      Winnipeg 
Deborah      Non-Winnipeg 
Jacqueline   Winnipeg 
Helen        Winnipeg 
David        Winnipeg 
James        Non-Winnipeg 
Michael      Winnipeg 
Ruth         Non-Winnipeg 
Joel         Non-Winnipeg 
Donna        Winnipeg 
Roger        Winnipeg 
Yao          Winnipeg 
Elizabeth    Winnipeg 
Tim          Non-Winnipeg 
Susan        Non-Winnipeg 
proc contents data=htwt_reg;       /* Begin a PROC step */
run;                               /* End the PROC step */
    /* View the values of the 1st 10 observations */
proc print data=htwt_reg(obs=10);  /* Begin a PROC step */
run;                               /* End the PROC step */

Contact: Charles Burchill       Telephone: (204) 789-3429
Manitoba Centre for Health Policy
Department of Community Health Sciences, University of Manitoba
4th floor Brodie Centre
408 - 727 McDermot Avenue
Winnipeg, Manitoba R3E 3P5       Fax: (204) 789-3910
Last modified on Friday, 26-Aug-2005 11:10:43 CDT