The MCHP SAS MANUAL - Create Clinical data set - program

         

Home    Contents

GENERAL GUIDELINES:
Windows in SAS
File management

The SAS Program
Program syntax
Debugging tips


 USING SAS PROGRAMMING TO: 
   
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
  
NON-PROGRAMMING 
      Alternatives

 
SAMPLE DATA SETS: 
 Height/weight
 Height/weight/region
 Simulated clinical data 
 Simulated Manitoba Health 
    

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 clinical_fmt.sas 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., cr_clinical.sas).
  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\
  formats\clinical_fmt.sas';

libname mydir 'c:\My Documents\My SAS Files\
  sasmanual\data';
filename clinread 'c:\My Documents\My SAS Files\
  sasmanual\data\clinical.dat';

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?';

run;

proc contents data=mydir.clinical;
run;

proc print data=mydir.clinical;
run;

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

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 Wednesday, 24-Aug-2005 13:37:43 CDT