<?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 Re: Averaging time/duration with dates in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368164#M2776</link>
    <description>&lt;P&gt;&amp;nbsp;The dates for d1(inital test) &amp;nbsp;and d2 (final test)&amp;nbsp;are listed in column form like this and each line refers to one indivual. Im trying to get the duration for each individual.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;04NOV2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;05JAN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;28MAY2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;02JUN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;02JUN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;13APR2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;05MAY2007&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;15OCT2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;26JUN2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;22FEB2013&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;19OCT2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;26NOV2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;12AUG2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;03JUL2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive tried putting the multple dates in order and hoping they would correalte with eachother and give me the time in months in the final column&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1 = '&lt;SPAN&gt;05MAY2007&lt;/SPAN&gt;' 15OCT2012'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2 = '&lt;SPAN&gt;04NOV2014&lt;/SPAN&gt;5' &amp;nbsp;'&lt;SPAN&gt;05JAN2015'&lt;/SPAN&gt;d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month = d2 - d1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month=intck('month',d1,d2);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;format d1 d2 date9.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;proc print data=sample;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Ive also tried to list the dates vertixally as &amp;nbsp;i was able to conver the char variables to sas dates like below but nothing has seemed to work.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1 = '&lt;SPAN&gt;05MAY2007&lt;/SPAN&gt;'d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;'15OCT2012'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2 = '&lt;SPAN&gt;04NOV2014&lt;/SPAN&gt;5'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;'&lt;SPAN&gt;05JAN2015'&lt;/SPAN&gt;d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month = d2 - d1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month=intck('month',d1,d2);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;format d1 d2 date9.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;proc print data=sample;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jun 2017 05:59:41 GMT</pubDate>
    <dc:creator>UGAstudent</dc:creator>
    <dc:date>2017-06-19T05:59:41Z</dc:date>
    <item>
      <title>Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368141#M2771</link>
      <description>&lt;P&gt;I was wondering if anyone could help me find ea simple way or code that would give me the difference in dates in like months or any unit of time? For example, I need the first line of date 2 :28/05/2015 or (May 28 2015) subtracted from Date 1: 18/08/2007 or (August 18 2007) which would be approximately a duration of 8 years. Then for all the observations for those durations an average in years or months? Would I have to recode this date? Which procedure would I use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Date 2&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28/05/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15/06/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/04/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/12/14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18/06/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18/06/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;11/3/15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4/12/14&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;14/04/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18/12/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12/3/15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/04/2015&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date 1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;18/08/2007&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15/01/2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;24/07/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;22/05/2013&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/12/12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;26/03/2015&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;23/09/2014&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7/8/13&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7/3/08&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;17/12/2012&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7/1/12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;25/09/2014&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 02:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368141#M2771</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T02:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368142#M2772</link>
      <description>&lt;P&gt;1. Your dates are likely in character format. You're going to have make them consistent first, this usually means using INPUT to convert to a SAS date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Review how SAS stores dates - ie as the number of days since Jan 1, 1960&lt;/P&gt;
&lt;P&gt;3. How do you know which dates you need to calculate from?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Since #2 is true, you can subtract dates directly for duration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sample;
d1 = '01Jan2017'd;
d2 = '31Jan2017'd;

n_days = d2 - d1;
format d1 d2 mmddyy10.;

run;

proc print data=sample;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 02:40:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368142#M2772</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T02:40:50Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368145#M2773</link>
      <description>&lt;P&gt;with reference to what &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; mentioned you could try the intck function as well to get the difference in day, month, year etc., in the intck function you have to replace the first argument with any of the above words&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;n_days=intck('day',d1,d2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 03:22:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368145#M2773</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-19T03:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368158#M2774</link>
      <description>Thanks! I’ve been able to calculate one date, but I have 477 observations. Is their a way i can do multiple dates at one time? Everything Ive tried so far hasn’t worked. The only thing that shows are the first date.&lt;BR /&gt;</description>
      <pubDate>Mon, 19 Jun 2017 05:43:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368158#M2774</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T05:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368159#M2775</link>
      <description>&lt;P&gt;Post what you've tried. And post what you want based on your supplied data above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 05:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368159#M2775</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T05:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368164#M2776</link>
      <description>&lt;P&gt;&amp;nbsp;The dates for d1(inital test) &amp;nbsp;and d2 (final test)&amp;nbsp;are listed in column form like this and each line refers to one indivual. Im trying to get the duration for each individual.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;04NOV2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;05JAN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;28MAY2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;02JUN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;02JUN2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;13APR2015&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;05MAY2007&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;15OCT2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;26JUN2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;22FEB2013&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;19OCT2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;26NOV2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;12AUG2014&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;03JUL2012&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ive tried putting the multple dates in order and hoping they would correalte with eachother and give me the time in months in the final column&amp;nbsp;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1 = '&lt;SPAN&gt;05MAY2007&lt;/SPAN&gt;' 15OCT2012'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2 = '&lt;SPAN&gt;04NOV2014&lt;/SPAN&gt;5' &amp;nbsp;'&lt;SPAN&gt;05JAN2015'&lt;/SPAN&gt;d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month = d2 - d1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month=intck('month',d1,d2);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;format d1 d2 date9.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;proc print data=sample;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Ive also tried to list the dates vertixally as &amp;nbsp;i was able to conver the char variables to sas dates like below but nothing has seemed to work.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d1 = '&lt;SPAN&gt;05MAY2007&lt;/SPAN&gt;'d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;'15OCT2012'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;d2 = '&lt;SPAN&gt;04NOV2014&lt;/SPAN&gt;5'd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;'&lt;SPAN&gt;05JAN2015'&lt;/SPAN&gt;d;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month = d2 - d1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;n_month=intck('month',d1,d2);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;format d1 d2 date9.;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;proc print data=sample;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;run;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 05:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368164#M2776</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T05:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368261#M2777</link>
      <description>&lt;P&gt;Wait!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you have a text file that contains the data for two columns in succession?&lt;/P&gt;
&lt;P&gt;Then you must first put these side-by-side.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please post an example (use the {i} box for correct posting) of your input data as-is.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368261#M2777</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-19T12:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368490#M2783</link>
      <description>&lt;P&gt;I have attached two files, one in an excel file and one with a word document if thats what you mean by text file? Heres the code im trying to use to calculate the difference.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data sample;
d1 = '24JAN2002'd;


d2 = '26MAR2015'd;

n_month = d2 - d1;
n_month=intck('month',d1,d2);
format d1 d2 date9.;

run;

proc print data=sample;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 20:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368490#M2783</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T20:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368493#M2785</link>
      <description>&lt;P&gt;The sample was to demonstrate how to do a calculation. I didn't expect you to type in your data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For first step should be to import your data into SAS, that may mean using proc import or an import task.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have a SAS dataset you can refer to your variables directly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see the tutorials here:&lt;/P&gt;
&lt;P&gt;support.sas.com/training/tutorials&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are YouTube videos as well as a link to the free e-course.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 21:05:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368493#M2785</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T21:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368505#M2787</link>
      <description>&lt;P&gt;Yes &amp;nbsp;I have successfully imported my data and im using sas studio online.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/* Generated Code (IMPORT) */
/* Source File: symptoms.xlsx */
/* Source Path: /folders/myfolders/sasuser.v94 */
/* Code generated on: 6/16/17, 2:03 PM */

%web_drop_table(WORK.IMPORT);


FILENAME REFFILE '/folders/myfolders/sasuser.v94/symptoms.xlsx';

PROC IMPORT DATAFILE=REFFILE
	DBMS=XLSX
	OUT=WORK.IMPORT;
	GETNAMES=YES;
	SHEET="Master";
RUN;

PROC CONTENTS DATA=WORK.IMPORT; RUN;


%web_open_table(WORK.IMPORT);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two variables of interest are in my data set which are Int_date and ART_date. I was able to copy and past all the values of each variable into the below command i found on the sas webside to convert them to sas dates and they gave me an output of converted dates.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.import;
   input   chardate3 $10. ;
   datalines;
  21/09/2005 
;

data work.import;
   set one;
  
   sasdate3=input(chardate3,ddmmyy10.);
  
   format   sasdate3 date9.  ;
run;

proc print;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then took the output data and tried to copy it into the below code so I coud convert them but i am unablee to get more than one subtraction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.import;
ART_date = '24JAN2002'd;


Int_date = '26MAR2015'd;

n_month = Int_date - ART_date;
n_month=intck('month',ART_date, Int_date);
format ART_date Int_date date9.;

run;

proc print data=work.import;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 22:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368505#M2787</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T22:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368508#M2788</link>
      <description>&lt;P&gt;Your first set of code is correct, the latter is not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It should be&amp;nbsp;a single step and your actually erasing your imported data when you do that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data date_difference ; *New dataset being created;
  
set import; *your imported data;

date_diff = art_date - int_date; *calculate date difference;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 22:15:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368508#M2788</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T22:15:10Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368521#M2789</link>
      <description>&lt;P&gt;I replaced the second half but I am still unable to input more than one date and get an output of more than one date. The code beow gives me an output where it shows the difference in days. Where should i add the additional dates because when i add them to the spots where '24JAN2003' and '26MAR2015' the code will not run&lt;/P&gt;&lt;PRE&gt;art_date = '24JAN2003'd;
int_date = '26MAR2015'd;


data date_difference ; *New dataset being created;
set import; *your imported data;
date_difference = int_date- art_date; *calculate date difference;

run;

proc print data=work.import;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 22:53:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368521#M2789</guid>
      <dc:creator>UGAstudent</dc:creator>
      <dc:date>2017-06-19T22:53:19Z</dc:date>
    </item>
    <item>
      <title>Re: Averaging time/duration with dates</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368522#M2790</link>
      <description>&lt;P&gt;YOU DO NOT NEED TO TYPE IN ANY DATES. THAT WAS TO ILLUSTRATE AN EXAMPLE, USE YOUR DATA.&lt;/P&gt;
&lt;P&gt;RUN THE EXACT CODE BELOW.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FILENAME REFFILE '/folders/myfolders/sasuser.v94/symptoms.xlsx';

PROC IMPORT DATAFILE=REFFILE
	DBMS=XLSX
	OUT=UGAStudent_DATA;
	GETNAMES=YES;
	SHEET="Master";
RUN;

data date_difference ; *New dataset being created;
  
set UGAStudent_DATA; *your imported data;

date_diff = art_date - int_date; *calculate date difference;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Jun 2017 22:56:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Averaging-time-duration-with-dates/m-p/368522#M2790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-19T22:56:53Z</dc:date>
    </item>
  </channel>
</rss>

