<?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 Counting number of months in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7828#M206</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Feb 2012 17:24:58 GMT</pubDate>
    <dc:creator>Fol_</dc:creator>
    <dc:date>2012-02-21T17:24:58Z</dc:date>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7817#M195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i have a large data set that has details of when a client first made a deposit and the last date of deposit. For instance Clent A has first_date_deposit as 15/07/2003 and last_date_deposit as 24/02/2010.(this is the date format in the dataset)&amp;nbsp; I want to create a new variable that will display the total number of months that has elapsed between the first date of deposit and last date of deposit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7817#M195</guid>
      <dc:creator>Fol_</dc:creator>
      <dc:date>2012-02-20T15:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7818#M196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Question: When you say total number of months, do you mean the actual calender months in between or only the months that have deposits?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the former, all you need to apply intck() function on two dates of yours, marking 'month' as the unit of intervals; for the later, you need to count the events happening within the same customer ID, which can be done using numerous ways, such as data step, proc SQL, freq, mean etc.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:32:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7818#M196</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-02-20T15:32:40Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7819#M197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; try to use INTCK function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7819#M197</guid>
      <dc:creator>sassharper</dc:creator>
      <dc:date>2012-02-20T15:35:39Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7820#M198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the interval functions to determine the number of month boundaries that have to be crossed to get from one date to another, but wouldn't it be more accurate to just use the number of days?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That can be computed by just subtracting the two dates.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 15:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7820#M198</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-20T15:37:14Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7821#M199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you want start date and end date has the same day when passing a month. not like intnx() only concentrate on first day every month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;data _null_;
infile datalines dlm=' ';
input start : ddmmyy12. end : ddmmyy12.;
number=intck('month',start-day(start)+1,end-day(start)+1);
put number= ;
datalines;
15/07/2003 14/08/2010
;
run;

&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 09:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7821#M199</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-02-21T09:42:08Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7822#M200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks for all the suggestions. I am not familiar with proc codes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But can i use the column label with the INTCK statement instead of date such as &lt;/P&gt;&lt;P&gt;no_of_month=INTCK('month', first_date_dep, last_date_dep); so counting the number of months between the first date of deposit and last date of deposit&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 14:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7822#M200</guid>
      <dc:creator>Fol_</dc:creator>
      <dc:date>2012-02-21T14:37:48Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7823#M201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as long as you are aware that Jan31st to Feb 1st will result in a greater value than Jan1st to Jan 31st.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 14:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7823#M201</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-21T14:40:27Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7824#M202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you Art. But please can you elaborate? I'm not sure i understand or can you suggest a query for determining the number of months elapsed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 14:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7824#M202</guid>
      <dc:creator>Fol_</dc:creator>
      <dc:date>2012-02-21T14:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7825#M203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is why I was suggesting using days elapsed rather than months.&amp;nbsp; If you have to use months, then I would suggest ensuring that you use the 'c' alignment argument.&amp;nbsp; It is easiest to show with an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; informat date1 date2 date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format date1 date2 date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input date1 date2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; months1=intck('month',date1,date2);&lt;/P&gt;&lt;P&gt;&amp;nbsp; months2=intck('month',date1,date2,'c');&lt;/P&gt;&lt;P&gt;&amp;nbsp; days=date2-date1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; cards;&lt;/P&gt;&lt;P&gt;01feb2010 28feb2010&lt;/P&gt;&lt;P&gt;03feb2010 02mar2010&lt;/P&gt;&lt;P&gt;03feb2010 03mar2010&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Running the above code will produce a file containing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date2&amp;nbsp;&amp;nbsp;&amp;nbsp; months1&amp;nbsp;&amp;nbsp;&amp;nbsp; months2&amp;nbsp;&amp;nbsp;&amp;nbsp; days&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01FEB2010&amp;nbsp;&amp;nbsp;&amp;nbsp; 28FEB2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03FEB2010&amp;nbsp;&amp;nbsp;&amp;nbsp; 02MAR2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 27&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 03FEB2010&amp;nbsp;&amp;nbsp;&amp;nbsp; 03MAR2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 28&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;As you can see, without the 'c' argument, the intck function only counts the number of month boundaries that have to be crossed to get to one date from another date.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;With it, it still only counts the number of boundaries that have to be crossed, but at least using the day of the month as the boundary.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Days, on the other hand, I think gives a more accurate picture.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7825#M203</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-21T15:31:10Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7826#M204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thank you Art, i agree with the argument. I will try to compute the days elapsed instead and divide that by 12 to get number of months.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:39:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7826#M204</guid>
      <dc:creator>Fol_</dc:creator>
      <dc:date>2012-02-21T15:39:09Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7827#M205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then one more suggestion.&amp;nbsp; You might want to use:&lt;/P&gt;&lt;P&gt;&amp;nbsp; months=yrdif(date1, date2,'age')*12;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 15:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7827#M205</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-02-21T15:51:55Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7828#M206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Thanks a lot&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 17:24:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7828#M206</guid>
      <dc:creator>Fol_</dc:creator>
      <dc:date>2012-02-21T17:24:58Z</dc:date>
    </item>
    <item>
      <title>Counting number of months</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7829#M207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wouldn't you want to take the number of days divided by 30, not 12, to get an approximation of the number of months?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;270 days / 12&amp;nbsp; = 22.5 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;270 days / 30 = 9 months&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Feb 2012 17:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Counting-number-of-months/m-p/7829#M207</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2012-02-21T17:41:58Z</dc:date>
    </item>
  </channel>
</rss>

