Sample Data Sets: Clinical - Program

This program can be used to create a SAS data set called "clinical". For subsequent sessions, the saved program can be run again to re-create the "clinical" data set, or the program can be slightly altered, as shown, to save a permanent SAS version of the data set.

  1. Type the following program directly into the SAS Program Editor window (the options ls=min statement can be left out, as well as the comment lines, if desired).
  2. Ensure that the clinical data set is accessible by SAS (e.g., from within the web browser, use the File/Save As command to save the data to a directory accessible by SAS. The browser will offer txt as one of the file extensions, so the data set could be named, for example, clinical.txt).
    Note that the LIBNAME and FILENAME statements will need to be changed to reflect the actual file path and the data set name, e.g., the program below references the clinical data with a different file extension name (clinical.dat).
  3. Ensure that the material in is read in from a file accessible by SAS. This file is required for attaching value labels to the gender, diagnosis, and 1/0 (yes/no) codes. Note that the %INCLUDE statement will need to be changed to reflect the actual file path and name.
  4. Save the program (e.g.,
  5. Submit the program for processing.
  6. Check both log and output windows to ensure the program ran accurately
  7. 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).
*   f=My SAS Files\sasmanual\clinical_cr      *;
*                                             *;
*This file creates the "clinical" SAS data    *;
*set.  Code is included for saving it as a    *;
*permanent or temporary SAS data set:         *;
* 1) Permanent - ensure an asterisk begins the*;
*         statement "data clinical" and that  *;
*         no asterisk precedes                *;
*         "data mydir.clinical"               *;
* 2) Temporary - ensure an asterisk precedes  *;
*         the statement "data mydir.clinical" *;
*         and that no asterisk precedes "data *;
*         clinical".  Also, the libname       *;
*         statement is not needed.            *;

options ls=min;

%include 'c:\My Documents\My SAS Files\sasmanual\

libname mydir 'c:\My Documents\My SAS Files\
filename clinread 'c:\My Documents\My SAS Files\

data mydir.clinical;/* SAVE AS PERMANENT SAS DATA SET*/
*data clinical;     /* SAVE AS TEMPORARY SAS DATA SET*/
   infile clinread;
   input   @1   id        $3.
           @4   gender    $1.
           @5   dob       MMDDYY6.
           @11  visit     MMDDYY6.
           @17  prim_dx   $2.
           @19  sec_dx    $2.
           @21  hr        3.
           @24  sbp       3.
           @27  dbp       3.
           @30  vitamins  $1.
           @31  pregnant  $1.;

   LABEL   id       = 'Pt. Number'
           gender   = 'Gender'
           dob      = 'Date of Birth'
           visit    = 'Visit Date'
           prim_dx  = 'Primary DX'
           sec_dx   = 'Secondary DX'
           hr       = 'Heart Rate'
           sbp      = 'Systolic Blood Pressure'
           dbp      = 'Diastolic Blood Pressure'
           vitamins = 'Pt. Taking Vitamins?'
           pregnant = 'Is Pt. Pregnant?';


proc contents data=mydir.clinical;

proc print data=mydir.clinical;

proc print data=mydir.clinical;
format prim_dx sec_dx $dxcodes.
       dob visit mmddyy8.
       gender $gender.
       vitamins pregnant $yesno.;