<?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 sas date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-date/m-p/90838#M19216</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have a dataset with a character variable 20080824. How can i convert this to date9. format?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Jul 2013 17:31:55 GMT</pubDate>
    <dc:creator>kushsas</dc:creator>
    <dc:date>2013-07-25T17:31:55Z</dc:date>
    <item>
      <title>sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-date/m-p/90838#M19216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have a dataset with a character variable 20080824. How can i convert this to date9. format?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2013 17:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-date/m-p/90838#M19216</guid>
      <dc:creator>kushsas</dc:creator>
      <dc:date>2013-07-25T17:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-date/m-p/90839#M19217</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't convert directly a created variable from alpha to numeric other than when you input it so you will need to create a new variable and, once satisfied with the result, drop the old one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;format newdatevar date9.;&lt;/P&gt;&lt;P&gt;newdatevar = input(trim(curdatevar), YYMMDD8.);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;once convinced that the result is good, you add&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;data mydata(rename=(newdatevar=curdatevar);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set mydata;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format newdatevar date9.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newdatevar = input(trim(curdatevar), YYMMDD8.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop curdatevar;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that the newly created variable can bear the same variable name as the old character variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can be done in a datastep, a few procedures or with proce SQL, the syntax is slightly different but the concept is the same, use input to read a char string as a given format, here YYMMDD8. and make sure that you specify the format of your variable as otherwise you will have the integer representation of the number of day since 01/01/1960 of that date (as it is stored) instead of your date9.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Vincent&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Jul 2013 17:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-date/m-p/90839#M19217</guid>
      <dc:creator>Vince28_Statcan</dc:creator>
      <dc:date>2013-07-25T17:57:52Z</dc:date>
    </item>
  </channel>
</rss>

