*Importing the ORISE WDS Master Roster file;
PROC IMPORT OUT= WORK.roster
DATAFILE= "C:\SAS_Examples\ORISEWDS_d1.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
/************************************************************************************
Example 1 - Selecting Y12 workers
FAC code 6 is for Y12
FAC1-Fac10 are checked to determine if they were ever employed at Y12
************************************************************************************/
Data y12;
set roster;
if fac1= '6' or fac2= '6' or fac3= '6' or fac4= '6'
or fac5= '6' or fac6= '6' or fac7= '6' or fac8= '6' or fac8= '6' or fac9= '6'
or fac10= '6';
run;
*Limit selection to Males at Y12;
Data y12_males;
set y12;
where sex='M';
run;
/************************************************************************************
Example 2 - Selecting vital status for Y12 males
Import the Master vital status file
************************************************************************************/
PROC IMPORT OUT= WORK.vital
DATAFILE= "C:\SAS_Examples\ORISEWDS_d6.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
proc sort data=y12_males;
by id;
run;
proc sort data=vital;
by id;
run;
Data Y12_males_vital;
merge y12_males (in=a) vital (in=b) ;
by id;
if a;
run;
/************************************************************************************
Example 3 - Selecting deceased males at Y12 and their cause of death
Import the Death file
************************************************************************************/
PROC IMPORT OUT = WORK.death
DATAFILE = "C:\SAS_Examples\ORISEWDS_d7.csv"
DBMS =CSV REPLACE;
GETNAMES =YES;
DATAROW=2;
RUN;
proc sort data=y12_males;
by id;
run;
proc sort data=death;
by id;
run;
*Merge death data into Y12-males*;
Data Y12_males_death;
merge y12_males (in=a) death (in=b) ;
by id;
if a;
run;
*Remove Y12_males that do not have death data (i.e. ICD death code)*;
Data y12_males_death;
set y12_males_death;
where icd_code ne '';
run;
/************************************************************************************
Example 4 - Employment data for all males who were ever hired at
Y12 between 1980 and 2000
Import the Employment data
************************************************************************************/
PROC IMPORT OUT= WORK.employ
DATAFILE= "C:\SAS_Examples\ORISEWDS_d2.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
RUN;
proc sort data=y12_males;
by id;
run;
proc sort data=employ;
by id;
run;
*Merge death data into Y12-males*;
Data Y12_males_employ;
merge y12_males (in=a) employ (in=b) ;
by id;
if a;
run;
*Convert Hiredate from character to numeric*;
data y12_males_employ;
set y12_males_employ;
format hire_date mmddyy10.;
hire_date=input(trim(hiredate),MMDDYY10.);
run;
*Only select workers that were ever employed between 1980-2000*;
data y12_males_employ;
set y12_males_employ;
where 1980 ≤ year(hire_date) ≤ 2000;
run;
/************************************************************************************
Example 5 - Y12 males ever hired between 1980-2000 and their vital status
************************************************************************************/
proc sort data=y12_males_employ out=y12_males_employ_unique nodupkey;
keep id;
by id;
run;
proc sort data=y12_males_vital;
by id;
run;
Data y12_males_employ_vital;
merge y12_males_employ_unique (in=a) y12_males_vital (in=b) ;
by id;
if a and b ;
run;
*Remove records without a vital status*;
data y12_males_employ_vital;
set y12_males_employ_vital;
where status ne '';
run;