DATA Step, Macro, Functions and more

Effect of lagtime on the number of cases using hospital discharge data

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 143
Accepted Solution

Effect of lagtime on the number of cases using hospital discharge data

[ Edited ]

I have a hospital discharge data with few key date information, that are data input date (the date indicates when clerical staff at hospital actually input the record in the database) and date of birth. Because, premature babies tend to have significantly longer stay at hospital, we might miss eligible cases if we select cases too soon, in contrast, we might lose time if we select cases too late. Below code, shows my attempt to assess lag time between data input date and date of birth to see how such lagtime affects number of cases available by each month. 

 

Any suggestions to solve the problem that I end up with negative "month_diff" where month of "data input date" is smaller than the month of birth date but in different years, i.e. date_input_date(20160201)- birthdate(20150712)?

 

proc import datafile="...\data100.csv"
out=have
dbms=csv replace;
getnames=yes;
run;

data temp(drop=date_input1 birth_date); 
set have;
date_input1=input(put(date_input,8.),yymmdd8.);
month_input=month(date_input1);
birth_date=input(put(patient_birth_date,8.),yymmdd8.);
month_birth=month(birth_date);
month_diff=month_input-month_birth;

date_input6=substr(left(date_input),1,6);
date_birth6=substr(left(patient_birth_date),1,6);
month_diff6=date_input6-date_birth6;
case=1;
run;

proc means data=temp maxdec=1 noprint;
class date_birth6;
var case;
output out=counts_bd(drop=_type_ _freq_) 
sum=/autoname;
proc means data=temp maxdec=1 noprint;
class date_input6;
var case;
output out=counts_prod(drop=_type_ _freq_) 
sum=/autoname;

proc means data=temp maxdec=1 noprint;
class date_birth6;
var month_diff;
output out=counts_birth6(drop=_type_ _freq_) 
sum=/autoname;
proc means data=temp maxdec=1 noprint;
class date_input6;
var month_diff6;
output out=counts_prod6(drop=_type_ _freq_) 
sum=/autoname;
run;

 Thanks for your time indeed.


Accepted Solutions
Solution
‎07-10-2017 04:25 PM
PROC Star
Posts: 1,760

Re: Effect of lagtime on the number of cases using hospital discharge data

[ Edited ]

1- Something is wrong here.

You can't use DATE_INPUT as a SAS date and as a string like you do:

DATE_INPUT1=input(put(DATE_INPUT,8.),yymmdd8.);

DATE_INPUT6=substr(left(DATE_INPUT),1,6);

2- Have you tried

MONTH_DIFF=intck('month',MONTH_BIRTH,MONTH_INPUT);

Look at the different parameters for this function.

View solution in original post


All Replies
Solution
‎07-10-2017 04:25 PM
PROC Star
Posts: 1,760

Re: Effect of lagtime on the number of cases using hospital discharge data

[ Edited ]

1- Something is wrong here.

You can't use DATE_INPUT as a SAS date and as a string like you do:

DATE_INPUT1=input(put(DATE_INPUT,8.),yymmdd8.);

DATE_INPUT6=substr(left(DATE_INPUT),1,6);

2- Have you tried

MONTH_DIFF=intck('month',MONTH_BIRTH,MONTH_INPUT);

Look at the different parameters for this function.

Frequent Contributor
Posts: 143

Re: Effect of lagtime on the number of cases using hospital discharge data

Just wanted to post my final program here, in case if anyone needs.

data temp; set have;
days= intck('days',input(patient_birth_date ,yymmdd8.),input(input_date,yymmdd8.));
birth_date=input(put(patient_birth_date,8.),yymmdd8.);
month_birth=month(birth_date);

pro_date=input(put(input_date,8.),yymmdd8.);
month_pro=month(pro_date);
year_pro=year(pro_date);
case=1;
run;

proc print data=temp(obs=10);
run;

proc means data=temp n mean clm median min max maxdec=0;
class birth_date;
var days;
format birth_date monname.;
run;

Thanks. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 87 views
  • 1 like
  • 2 in conversation