<?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: calculating time in months from month and year variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804394#M33414</link>
    <description>&lt;P&gt;If your month and year variables are numeric use MDY() function to generate dates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=mdy(month,1,year);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your month and year variables are character use INPUT() function to generate dates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=input(catx('/',month,1,year),mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have two date values use INTCK() to count months.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;interval=intck('month',date1,date2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 27 Mar 2022 15:21:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-03-27T15:21:20Z</dc:date>
    <item>
      <title>calculating time in months from month and year variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804393#M33413</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;i would appreciate your help as i'm stuck.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to calculate a study period by using "beginning of the study" variables (2 variables: month and year ) and the "end of the study variables" ( month and year). i tried concantenating the month and year period for begginning and end of the study but i dont know how else to go about it&lt;/P&gt;
&lt;P&gt;example of what i want :&amp;nbsp; if beginning date (ddmmyy) is 01082010 and end date is 01072011(ddmmyy), i want a new variable titled "study_period" which will have a value of 12 (i.e 12 months since the difference in the dates is a year).&lt;/P&gt;
&lt;P&gt;these date variables ic reated using catt function is character&lt;/P&gt;
&lt;P&gt;thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
DATA TRIAL;
Set TCR.DUMMY4;
Col_beg = catt(1,FirstRxDtSEERMonth,FirstRxDtSEERYear); 
/** these are the variables for the beginning of the study; i added 1 as the first day of the month, followed by the time in month, and then in year**/
Col_end = catt(1,datelastcontmonth,datelastcontyear);
/** these are the variables for the end of the study; i added 1 as the first day of the month, followed by the time in month, and then in year**/
Run;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT DATA = TRIAL (OBS = 10);&lt;BR /&gt;VAR COL_beg col_end;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA TRIAL2;
Set Trial;&lt;BR /&gt;date_beg = input(col_beg,ddmmyy10.); /**trying to convert to date format but didnt work**/
date_end = input(col_end,ddmmyy10.); /*log error: Invalid argument to function INPUT at line 49 column 12.*/&lt;BR /&gt;run;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sas output" style="width: 890px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69862iFC751B8FF023F769/image-size/large?v=v2&amp;amp;px=999" role="button" title="date_sas output.jpg" alt="sas output" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;sas output&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 15:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804393#M33413</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-03-27T15:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: calculating time in months from month and year variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804394#M33414</link>
      <description>&lt;P&gt;If your month and year variables are numeric use MDY() function to generate dates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=mdy(month,1,year);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your month and year variables are character use INPUT() function to generate dates.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date=input(catx('/',month,1,year),mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Once you have two date values use INTCK() to count months.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;interval=intck('month',date1,date2);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Mar 2022 15:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804394#M33414</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-27T15:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: calculating time in months from month and year variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804400#M33415</link>
      <description>&lt;P&gt;Thank you so much! it worked!&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 15:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/calculating-time-in-months-from-month-and-year-variables/m-p/804400#M33415</guid>
      <dc:creator>Banke</dc:creator>
      <dc:date>2022-03-27T15:38:59Z</dc:date>
    </item>
  </channel>
</rss>

