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., htwtprog.sas).
  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).

************************************
* f=htwt_cr.sas                    *
*                                  *
* 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 */
cards;
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 */