I have two questions... 1. Is there a way to simplify the repetitiveness of the PROC SQLs below? Specifically, I used repeated proc sqls to STEP A) Take out any inpatient claims with the DX codes 123, 12345 and compile them into "compiled" dataset, AND STEP B) Take out all eligibility claims from eligibility files if their enrolid shows up in "compiled" 2. I think if a patient has enrolID 12345 in year 2011, and then loses eligibility, another patient may appear as enrolID 12345. How can I change the code below to make sure STEP B takes out eligibility claims that match on enrolID and a corresponding "year" variable (assuming both eligibility claims and inpatient claims has a common 'year' variable?) Step A and step B in its current state below. /*0.1.0 SETUP LIBS */
libname raw "N:\" ACCESS = READONLY;
libname temp "M:\";
/*0.1.1 GENERATE LIST OF PTS WITH CORRECT DX CODE*/
PROC SQL NOPRINT;
CREATE TABLE gg_def10 AS
SELECT *
FROM 'N:\ccaes103.sas7bdat'
WHERE (DX1 IN ('123', '12345'))
AND (AGE >= (18));
QUIT;
PROC SQL NOPRINT;
CREATE TABLE gg_def11 AS
SELECT *
FROM 'N:\ccaes113.sas7bdat'
WHERE (DX1 IN ('123', '12345'))
AND (AGE >= (18));
QUIT;
PROC SQL NOPRINT;
CREATE TABLE gg_def12 AS
SELECT *
FROM 'N:\ccaes122.sas7bdat'
WHERE (DX1 IN ('123', '12345'))
AND (AGE >= (18));
QUIT;
PROC SQL NOPRINT;
CREATE TABLE gg_def13 AS
SELECT *
FROM 'N:\ccaes130.sas7bdat'
WHERE (DX1 IN ('123', '12345'))
AND (AGE >= (18));
QUIT;
/*Stack the inpatient claims from 2010 - 2013Q3*/
data temp.compiled;
set gg_def10 gg_def11 gg_def12 gg_def13;
/*0.1.1 CLEAN ELIGIBILITY */
/*0.1.1.1 COLLAPSE ELIGIBILITY CLAIMS */
PROC SQL NOPRINT;
CREATE TABLE elig_10 AS
SELECT *
FROM 'N:\ccaet103.sas7bdat'
WHERE ENROLID IN (SELECT DISTINCT ENROLID from temp.compiled);
QUIT;
PROC SQL NOPRINT;
CREATE TABLE elig_11 AS
SELECT *
FROM 'N:\ccaet113.sas7bdat'
WHERE ENROLID IN (SELECT DISTINCT ENROLID from temp.compiled);
QUIT;
PROC SQL NOPRINT;
CREATE TABLE elig_12 AS
SELECT *
FROM 'N:\ccaet122.sas7bdat'
WHERE ENROLID IN (SELECT DISTINCT ENROLID from temp.compiled);
QUIT;
PROC SQL NOPRINT;
CREATE TABLE elig_13 AS
SELECT *
FROM 'N:\ccaet132.sas7bdat'
WHERE ENROLID IN (SELECT DISTINCT ENROLID from temp.compiled);
QUIT;
data temp.compiled_elig;
set elig_10 elig_11 elig_12 elig_13;
... View more