<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Effect of lagtime on the number of cases using hospital discharge data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374348#M89627</link>
    <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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(2016&lt;STRONG&gt;02&lt;/STRONG&gt;01)- birthdate(2015&lt;STRONG&gt;07&lt;/STRONG&gt;12)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks for your time indeed.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2017 20:24:51 GMT</pubDate>
    <dc:creator>Cruise</dc:creator>
    <dc:date>2017-07-10T20:24:51Z</dc:date>
    <item>
      <title>Effect of lagtime on the number of cases using hospital discharge data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374348#M89627</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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(2016&lt;STRONG&gt;02&lt;/STRONG&gt;01)- birthdate(2015&lt;STRONG&gt;07&lt;/STRONG&gt;12)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thanks for your time indeed.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 20:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374348#M89627</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-10T20:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Effect of lagtime on the number of cases using hospital discharge data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374371#M89631</link>
      <description>&lt;P&gt;1- Something is wrong here.&lt;/P&gt;
&lt;P&gt;You can't use &lt;FONT face="courier new,courier"&gt;DATE_INPUT&lt;/FONT&gt; as a SAS date&amp;nbsp;&lt;STRONG&gt;and&lt;/STRONG&gt; as a string like you do:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DATE_INPUT1=input(put(DATE_INPUT,8.),yymmdd8.);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;DATE_INPUT6=substr(left(DATE_INPUT),1,6);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;2- Have you tried&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt; MONTH_DIFF=intck('month',MONTH_BIRTH,MONTH_INPUT);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;Look at the different parameters for this function.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 21:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374371#M89631</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-10T21:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Effect of lagtime on the number of cases using hospital discharge data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374694#M89750</link>
      <description>&lt;P&gt;Just wanted to post my final program here, in case if anyone needs.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2017 20:19:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Effect-of-lagtime-on-the-number-of-cases-using-hospital/m-p/374694#M89750</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2017-07-10T20:19:50Z</dc:date>
    </item>
  </channel>
</rss>

