Skip to main content

SAS Examples

To determine the FAC code for Y12 from the ORISEWDS_d1 - Master roster file, click on the header for FAC1:

SAS Example 1

The variable level for each header will be displayed.

SAS Example 2

Select the FACCODE code set and all associated values will be displayed.

Y12 is Facility Code 6:

SAS Example 3

Example overview using SAS 9.3

After downloading the ORISEWDS_d1 - Master roster file, select everyone that worked at Y12.

Refine the cohort

  1. Select all males at Y12

Determine the vital status for a cohort

  1. After downloading the ORISEWDS_d6 - Master vital status file, show the vital status of all males at Y12
  2. After downloading ORISEWDS_d7 - Death file, select all deceased males who worked at Y12 and their associated cause of death will be displayed.

Determine a cohort who worked in a particular time period

  1. After downloading the ORISEWDS_d2 - Employment data, select all males who were ever hired at Y12 between 1980 and 2000.
  2. Select all Y12 males that were ever employed between 1980 and 2000 and their associated vital status will be displayed.

*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;

Next: See R Examples

Share This Page:
To Top
ORISE

Contact Us
Oak Ridge Institute for Science and Education (ORISE) is managed for the U.S. Department of Energy (DOE) by Oak Ridge Associated Universities (ORAU). Files are built in .CSV and .XLS formats for use in Excel. Bibliographies are in Adobe Reader .PDF format - Privacy and Security Statement