Hi all,
With the following code I'm trying to
1) Compile all the inpatient claims files from 2010 - 2014;
2) Subset to only those with the right dx1 codes, right age, and then label which one is the "index claim". Eventually I want to just have those who are continuously enrolled +/- 1 year before and after index date.
The following code does not seem to work -- wondering what I should tweak?
/*Input codes*/
%let dx1_list = '123', '12345';
%let age_cutoff = 18;
/*0.1.0 SETUP LIBS */
libname raw "Z:\" ACCESS = READONLY;
/*0.1.1 GENERATE LIST OF PTS WITH ANY CLAIMS*/
data compiled_ip;
set raw.ccaes103 raw.ccaes113 raw.ccaes122 raw.ccaes132;
run;
data compiled_ip_index;
set compiled_ip;
where dx1 in (&dx1_list.) and age >= &age_cutoff.;
by enrolid svcdate;
if first.enrolid then do;
index_dt=svcdate;
end;
run;
If what you want is to have index_dt defined for every observation, you should do:
data compiled_ip_index;
do until(last.enrolid);
set compiled_ip;
where dx1 in (&dx1_list.) and age >= &age_cutoff.;
by enrolid svcdate;
if first.enrolid then index_dt = svcdate;
end;
run;
What did you log show? My initial guess is that you need to sort the file compiled_ip, by enrolid svcdate, prior to running the final datastep.
Art, CEO, AnalystFinder.com
Ahh thanks! That is it! Need to sort before...
Now what I have is index_date showing up as 18744 which doesn't appear to be in the MMDDYYYY format.
1) Any idea how I can get this date to show up in the right format?
2) Currently index_date is showing up only for the first.enroll_id (which is what I want) -- how do I apply that index_date for all subsequent claims with the same enrollid?
What do you mean by "not work"? What results did you expect, and what results did you get?
If what you want is to have index_dt defined for every observation, you should do:
data compiled_ip_index;
do until(last.enrolid);
set compiled_ip;
where dx1 in (&dx1_list.) and age >= &age_cutoff.;
by enrolid svcdate;
if first.enrolid then index_dt = svcdate;
end;
run;
Thank you so much! Read my mind!
My index_dt is currently showing up as 18744... or something that is unlike MMDDYYYY. Any idea how I can make it in the same format as the svc_dt? which is currently like 11/22/2014 or something.
Add the statement
format index_dt mmddyys10.;
to your data step.
I know that this is an old post, but I'm revisiting this code and it seems like the output just has the first enrolid observation and none of the following. Wondering if there is a way to get around this?
Try
data compiled_ip_index;
do until(last.enrolid);
set compiled_ip;
where dx1 in (&dx1_list.) and age >= &age_cutoff.;
by enrolid svcdate;
if first.enrolid then index_dt = svcdate;
output;
end;
format index_dt mmddyys10.;
run;
(untested)
This works!! Thank you!
Not sure which post your various comments are responding to. To keep the value for all records simply use a retain statement:
data compiled_ip_index; set compiled_ip; retain index_dt.; where dx1 in (&dx1_list.) and age >= &age_cutoff.; by enrolid svcdate; if first.enrolid then do; index_dt=svcdate; end; run;
As for the format, like @PGStats suggested, simply add a format statement.
Art, CEO, AnalystFinder.com
Apologies for the confusion.
Would the "retain" statement populate the index_dt value only for that specific enrolid?
Also, your post would count as a solution as well! Is there a way I can select two posts as a solution?
Thank you so much!
I don't care which post you mark as a solution .. that is totally up to you. You can read about the retain statement at: http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000214163.htm
Art, CEO, AnalystFinder.com
Hey cdubs,
The code identifies the index date. I am curious about how did you achieve the next step of finding who are continuously enrolled +/- 1 year before and after index date.
Thanks!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.