Listing 3.1 Data Input and Editing in EPICURE
! Read the data file
USETXT ../exdata/tbfchrt.csv @
! Define transformations to be carried out as data are read
TRAN IF brstat == 2 THEN DELETE ENDIF ;
IF dose > 0 THEN
dose = dose/100 ;
exposed = 1 ;
ELIF dose == 0 THEN
exposed = 0 ;
ELSE
exposed = %MV ; dose = %MV ;
ENDIF
@
TRAN aftcat = 1 + (aft >= 20) + (aft >= 30) +
(aft >= 40) ;
dcat = (dose > 0) + (dose >= 1) + (dose >= 3) ;
@
LEVELS aftcat 4 dcat 0:3 @
INPUT @
SHOW@
! Define missing values for dose and number of treatments
MISS numbtf > 990 @
! Create an exposure category variable
TRAN IF ISMISS(dose) THEN
expcat = 2 ;
dcat = %MV ;
ELSE
expcat = (dose > 0) ;
ENDIF
! Create a birth cohort indicator and compute log dose
bcohort = 1 + (byr >= 1910) + (byr >= 1920) ;
ldose = log(dose) ;
@
! Define levels for categorical variables
LEVELS bcohort expcat @
! Save all data in a BSF file
SAVE REPLACE @
! Write selected variables to a file
DATA id brstat byr bmo dxyr dxmo dose ldose numbtf aft dcat expcat aft
aftcat ; TO tbfex1.csv NAMES COMMA REPLACE @
SORT hosp - brstat @
! Select records with known dose and save selected variables in BSF file
SELECT expcat /= 2 @
SAVE id brstat byr dxyr dose expcat aft aftcat numbtf ;
TO tbfdose @
! List all of selected variables for all records with missing dose
! (the list will be printed on the screen)
SELECT expcat == 2 @
SUM brstat @
SETFORMAT id hosp brstat ; I5@
DATA id hosp brstat TO LOG @
QUIT@