<?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: convert month data to date data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127661#M260344</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data are already date variables that just have different formats attached then use INTNX() function to convert to first day of the month.&amp;nbsp; If they are character strings then use INPUT function.&amp;nbsp; If the first is a number like 199,010 that just happens to look like 6 digit YYYYMM string then convert it to string with the PUT function first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data check ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input s1 :$6. s2 :$9. @1 n1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d1 = input(s1,yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d2 = input(s2,date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d2m = intnx('month',d2,0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d3 = input(put(n1,z6.),yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format d: date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put (_all_) (=);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;199010 31OCT1990&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&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;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;s1=199010 s2=31OCT1990 n1=199010 d1=01OCT1990 d2=31OCT1990 d2m=01OCT1990 d3=01OCT1990&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Jul 2013 20:33:24 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2013-07-05T20:33:24Z</dc:date>
    <item>
      <title>convert month data to date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127660#M260343</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a question regarding dates in sas. I want to merge two datasets, one with a month variable formatted as "199010" and the other with a date variable formatted as "01OCT1990". I want to merge by the month. In this case "199010" and "01OCT1990" should be merged. How can I do that? I was thinking of several ways. One is that extract month and year of the two variables and merge by month and year. Another is to convert two variables to the dates variable and merge by one variable. But I am not sure how to convert "199010" to "01OCT1990" or "31OCT1990". Please help. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2013 20:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127660#M260343</guid>
      <dc:creator>SeanZ</dc:creator>
      <dc:date>2013-07-05T20:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: convert month data to date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127661#M260344</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your data are already date variables that just have different formats attached then use INTNX() function to convert to first day of the month.&amp;nbsp; If they are character strings then use INPUT function.&amp;nbsp; If the first is a number like 199,010 that just happens to look like 6 digit YYYYMM string then convert it to string with the PUT function first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data check ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input s1 :$6. s2 :$9. @1 n1 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d1 = input(s1,yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d2 = input(s2,date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d2m = intnx('month',d2,0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; d3 = input(put(n1,z6.),yymmn6.);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; format d: date9. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; put (_all_) (=);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;199010 31OCT1990&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&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;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;s1=199010 s2=31OCT1990 n1=199010 d1=01OCT1990 d2=31OCT1990 d2m=01OCT1990 d3=01OCT1990&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2013 20:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127661#M260344</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-07-05T20:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: convert month data to date data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127662#M260345</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi -&lt;/P&gt;&lt;P&gt;Assuming that your variables are recorded as character strings, your best bet is to create a SAS date variable and merge the 2 data sets by using this new variable.&lt;/P&gt;&lt;P&gt;As an illustration:&lt;/P&gt;&lt;P&gt;data have1;&lt;/P&gt;&lt;P&gt;month="199010";&lt;/P&gt;&lt;P&gt;value1=1;&lt;/P&gt;&lt;P&gt;date=input(month,yymmn6.);&lt;/P&gt;&lt;P&gt;format date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data have2;&lt;/P&gt;&lt;P&gt;day="01OCT1990";&lt;/P&gt;&lt;P&gt;value2=2;&lt;/P&gt;&lt;P&gt;date=input(day,date9.);&lt;/P&gt;&lt;P&gt;format date date9.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;merge have1 have2;&lt;/P&gt;&lt;P&gt;by date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;For more information about SAS date variables, check out: &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n0q9ylcaccjgjrn19hvqnd9cte8p.htm"&gt;http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#n0q9ylcaccjgjrn19hvqnd9cte8p.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Udo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Jul 2013 20:39:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-month-data-to-date-data/m-p/127662#M260345</guid>
      <dc:creator>udo_sas</dc:creator>
      <dc:date>2013-07-05T20:39:41Z</dc:date>
    </item>
  </channel>
</rss>

