<?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: How to Convert yyyy-mm-dd to DATE9 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365823#M275149</link>
    <description>&lt;P&gt;The Format of a SAS date variable has no impact on the ability to calculate intervals and such.&lt;/P&gt;
&lt;P&gt;I would suspect that your date variable(s) are actually character and you need a SAS date valued variable which would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateSas = input(yourdate,yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format DateSas date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the calculations you want there are many functions available but we would need an example of what you want to show specific examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2017 20:21:35 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-06-09T20:21:35Z</dc:date>
    <item>
      <title>How to Convert yyyy-mm-dd to DATE9</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365815#M275148</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have dates in my dataset in yyyy-mm-dd format. For example, 2016-09-26. I would like to calculate days with them, and need to format these accordingly. I've tried:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;format&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; variable &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;date9.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it doesn't work. Is there a way to convert this date format to a valid one that can be used for calculations? Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:06:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365815#M275148</guid>
      <dc:creator>yawenyu</dc:creator>
      <dc:date>2017-06-09T20:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Convert yyyy-mm-dd to DATE9</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365823#M275149</link>
      <description>&lt;P&gt;The Format of a SAS date variable has no impact on the ability to calculate intervals and such.&lt;/P&gt;
&lt;P&gt;I would suspect that your date variable(s) are actually character and you need a SAS date valued variable which would be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DateSas = input(yourdate,yymmdd10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format DateSas date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the calculations you want there are many functions available but we would need an example of what you want to show specific examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:21:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365823#M275149</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-09T20:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to Convert yyyy-mm-dd to DATE9</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365828#M275150</link>
      <description>&lt;P&gt;Thanks for your help! The date was indeed stored as a character value, so I was getting an invalid numeric value error message. The input&amp;nbsp;statement preceeding the format statement&amp;nbsp;did the trick.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2017 20:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Convert-yyyy-mm-dd-to-DATE9/m-p/365828#M275150</guid>
      <dc:creator>yawenyu</dc:creator>
      <dc:date>2017-06-09T20:47:44Z</dc:date>
    </item>
  </channel>
</rss>

