<?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 a date stored as a macro value to a sas date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758884#M239692</link>
    <description>&lt;P&gt;Where do you want to use this new "date" value? As another macro variable? Variable in a data step or proc sql?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;General solution without details is going to involve an Input function with a proper informat as the possibly cleanest solution. But which and where can bring up some details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; is hinting, I think, that when you make it may be the place to create the new value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Aug 2021 20:12:08 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-08-02T20:12:08Z</dc:date>
    <item>
      <title>convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758880#M239689</link>
      <description>&lt;P&gt;How can I convert the following text date stored in a macro variable into a sas date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let dt=September 16, 2005;&lt;/P&gt;&lt;P&gt;%put &amp;amp;dt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758880#M239689</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2021-08-02T20:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758881#M239690</link>
      <description>&lt;P&gt;How do you set the macro variable initially?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:06:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758881#M239690</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-02T20:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758883#M239691</link>
      <description>&lt;P&gt;I initially read it in as a parameter with the %quote() around it.&amp;nbsp; &amp;nbsp;Similar to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro xyz(dt);&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%xyz(%quote(September 16, 2005))&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:11:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758883#M239691</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2021-08-02T20:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758884#M239692</link>
      <description>&lt;P&gt;Where do you want to use this new "date" value? As another macro variable? Variable in a data step or proc sql?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;General solution without details is going to involve an Input function with a proper informat as the possibly cleanest solution. But which and where can bring up some details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; is hinting, I think, that when you make it may be the place to create the new value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758884#M239692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-02T20:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758885#M239693</link>
      <description>&lt;P&gt;I intend to use it as a date filter in a data step.&amp;nbsp; &amp;nbsp;I know I can convert the date by hand to someone more user friendly, but was hoping SAS could do it if it doesn't require really elaborate code.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758885#M239693</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2021-08-02T20:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758886#M239694</link>
      <description>So you type that unwieldy string manually into the code? Why don't you use a format that is easier to handle, like YYYYMMDD?</description>
      <pubDate>Mon, 02 Aug 2021 20:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758886#M239694</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-08-02T20:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758887#M239695</link>
      <description>Sorry, "something more user friendly"</description>
      <pubDate>Mon, 02 Aug 2021 20:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758887#M239695</guid>
      <dc:creator>Batman</dc:creator>
      <dc:date>2021-08-02T20:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: convert a date stored as a macro value to a sas date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758896#M239699</link>
      <description>&lt;P&gt;For macro variables, I suggest using text in the form of ddMMMyyyy, &lt;EM&gt;&lt;STRONG&gt;without any quotes&lt;/STRONG&gt;&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e, something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; %let d=05JUL2021 ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This tactic makes it easy to use macrovar-based dates in regular SAS code, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   set have;
   where date &amp;gt;="&amp;amp;d"d;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I.e., in the SAS code, just provide the trailing d, and the quotes - but they have to be double quotes to avoid masking the &amp;amp;d value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly for time, use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;%let t=15:05:20.05&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for date-times&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%let dt=03jul2021:12:20:30.10;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;whose use in a sas program might look like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let d=05jul2021;
%let t=15:30:15.05;
%let dt=03jul2021:12:20:30.10;

data _null_;
  d="&amp;amp;d"d;      put d=date9.;
  t="&amp;amp;t"t;      put t=time11.2;
  dt="&amp;amp;dt"dt;   put dt=datetime30.3;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 02 Aug 2021 20:52:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-a-date-stored-as-a-macro-value-to-a-sas-date/m-p/758896#M239699</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-08-02T20:52:09Z</dc:date>
    </item>
  </channel>
</rss>

