BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cdubs
Quartz | Level 8

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;
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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;

 

PG

View solution in original post

13 REPLIES 13
art297
Opal | Level 21

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

 

cdubs
Quartz | Level 8

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?

 

 

mkeintz
PROC Star

What do you mean by "not work"?  What results did you expect, and what results did you get?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
PGStats
Opal | Level 21

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;

 

PG
cdubs
Quartz | Level 8

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. 

PGStats
Opal | Level 21

Add the statement

 

format index_dt mmddyys10.;

 

to your data step.

PG
cdubs
Quartz | Level 8

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?

PGStats
Opal | Level 21

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)

 

PG
cdubs
Quartz | Level 8

This works!! Thank you! 

art297
Opal | Level 21

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

 

cdubs
Quartz | Level 8

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! 

art297
Opal | Level 21

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

Janabey
Calcite | Level 5

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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 2063 views
  • 6 likes
  • 5 in conversation