The MCHP SAS MANUAL - Create Height/Weight - 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 - Program

This program can be used to create a temporary SAS data set called "htwt" 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" 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 is one space, at column 11, and then SEX (also read in as character) is entered at column 12 (or the 12th space over from the beginning of the line). It must be entered at this 12th space if SAS is to pick up the values of SEX for each observation. AGE is read in as numeric, and can take up to two spaces, beginning at column 14 and finishing in column 15. 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).
*                    *
*                                  *
* This program creates a temporary *
* SAS data set using raw values    *
* entered for 18 observations.     *

data htwt;                  /* Begin the DATA step */
          /* Describe variable names and locations */
  input name $ 1-10 sex $ 12 age 14-15
        height 17-18 weight 20-22;
           /* Read the following lines of raw data */
Aubrey     M 41 74 170
Ron        M 42 68 166
Carl       M 32 70 155
Antonio    M 39 72 167
Deborah    F 30 66 124
Jacqueline F 33 66 115
Helen      F 26 64 121
David      M 30 71 158
James      M 53 72 175
Michael    M 32 69 143
Ruth       F 47 69 139
Joel       M 34 72 163
Donna      F 23 62  98
Roger      M 36 75 160
Yao        M  . 70 145
Elizabeth  F 31 67 135
Tim        M 29 71 176
Susan      F 28 65 131
;              /* End the lines of raw data */
run;         /* End the DATA step */

                 /* Obtain info on the data set */
proc contents data=htwt; /* Begin a PROC step */
run;                    /* End the PROC step */

      /* View the values of the 1st 10 observations */
proc print data=htwt(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 10:31:14 CDT