<?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: Can I convert a string &amp;quot;date&amp;quot; into a real date variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20336#M3186</link>
    <description>Thanks! I didn't know about using the double quoted literals. Previously when I used the single quotes the macro wouldn't be evaluated. The double quotes seem to fix the problem if I use the %str function.</description>
    <pubDate>Fri, 17 Apr 2009 00:17:56 GMT</pubDate>
    <dc:creator>WalterC</dc:creator>
    <dc:date>2009-04-17T00:17:56Z</dc:date>
    <item>
      <title>Can I convert a string "date" into a real date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20334#M3184</link>
      <description>I am trying to set up a report with the input dates always today and 1 week back. I am able to get these macro variables into the correct form as strings, but when I go to try to use them in a sql query (below) the fact that they are strings causes an error. I have thought about just using a data step and changing the format in the datastep, but for this particular query a datastep takes forever. Any suggestions would be very helpful. &lt;BR /&gt;
&lt;BR /&gt;
73   %let end_date_value =%sysfunc(today());&lt;BR /&gt;
74   %put &amp;amp;end_date_value;&lt;BR /&gt;
18003&lt;BR /&gt;
75&lt;BR /&gt;
76   %let start_date_value = %eval(&amp;amp;end_date_value-7);&lt;BR /&gt;
77   %put &amp;amp;start_date_value;&lt;BR /&gt;
17996&lt;BR /&gt;
78&lt;BR /&gt;
79   %let start_date = %sysfunc(putn(&amp;amp;start_date_value, date9.));&lt;BR /&gt;
80   %put &amp;amp;start_date;&lt;BR /&gt;
09APR2009&lt;BR /&gt;
81&lt;BR /&gt;
82   %let end_date = %sysfunc(putn(&amp;amp;end_date_value, date9.));&lt;BR /&gt;
83   %put &amp;amp;end_date;&lt;BR /&gt;
16APR2009&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table P as &lt;BR /&gt;
select *&lt;BR /&gt;
&lt;BR /&gt;
from table as rt&lt;BR /&gt;
where date  &amp;gt;= &amp;amp;start_date&lt;BR /&gt;
and date &amp;lt;= &amp;amp;end_date&lt;BR /&gt;
&lt;BR /&gt;
;&lt;BR /&gt;
quit;</description>
      <pubDate>Thu, 16 Apr 2009 23:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20334#M3184</guid>
      <dc:creator>WalterC</dc:creator>
      <dc:date>2009-04-16T23:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can I convert a string "date" into a real date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20335#M3185</link>
      <description>Explore using SAS data literals where the string is surrounded in double-quotes and suffixed with a "D" character, telling SAS that the character literal is to be interpreted as a DATE.  Or depending on the format (if not ddmmmyyyy or ddmmmyy format) you could also use the SAS INPUT function to read up a character string and let SAS covert it to a SAS numeric variable (internall represented as days since 1/1/1960).&lt;BR /&gt;
&lt;BR /&gt;
Have a look at the SAS support  &lt;A href="http://support.sas.com/" target="_blank"&gt;http://support.sas.com/&lt;/A&gt;  website and use the SEARCH facility to look for the phrase Working with Dates - you will find several DOCUMENTATION links and supplemental technical/conference papers referenced.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Fri, 17 Apr 2009 00:10:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20335#M3185</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-17T00:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can I convert a string "date" into a real date variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20336#M3186</link>
      <description>Thanks! I didn't know about using the double quoted literals. Previously when I used the single quotes the macro wouldn't be evaluated. The double quotes seem to fix the problem if I use the %str function.</description>
      <pubDate>Fri, 17 Apr 2009 00:17:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-convert-a-string-quot-date-quot-into-a-real-date-variable/m-p/20336#M3186</guid>
      <dc:creator>WalterC</dc:creator>
      <dc:date>2009-04-17T00:17:56Z</dc:date>
    </item>
  </channel>
</rss>

