<?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 convert macro variable to datetime in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616894#M180692</link>
    <description>&lt;P&gt;I have below macro variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%let&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;x=01JAN2020:00:00:00:447;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i want it to convert to datetime25.6;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can i do that ?&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2020 13:04:26 GMT</pubDate>
    <dc:creator>shubham1</dc:creator>
    <dc:date>2020-01-13T13:04:26Z</dc:date>
    <item>
      <title>convert macro variable to datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616894#M180692</link>
      <description>&lt;P&gt;I have below macro variable&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;%let&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;x=01JAN2020:00:00:00:447;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;i want it to convert to datetime25.6;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can i do that ?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 13:04:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616894#M180692</guid>
      <dc:creator>shubham1</dc:creator>
      <dc:date>2020-01-13T13:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: convert macro variable to datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616899#M180694</link>
      <description>&lt;A href="https://communities.sas.com/t5/SAS-Programming/Convert-macro-variable-to-datetime/m-p/608995#M177284" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Convert-macro-variable-to-datetime/m-p/608995#M177284&lt;/A&gt;</description>
      <pubDate>Mon, 13 Jan 2020 13:25:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616899#M180694</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2020-01-13T13:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: convert macro variable to datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616902#M180695</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/127952"&gt;@shubham1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have below macro variable&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;x=01JAN2020:00:00:00:447;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;i want it to convert to datetime25.6;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How can i do that ?&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Macro variables do not have formats. They are text strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to treat this macro variable as a SAS date/time value, so you can compare other date/time values to it to see if the other data/time value is before or after your macro variable &amp;amp;x, then it must be a number representing the number of seconds since midnight 1/1/60.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
	call symputx('x','01JAN2020:00:00:00.447'dt);
run;
%put &amp;amp;=x;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to display it in a specific format, for example in a label or title, you can apply formatting then.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title "This is a title showing the datetime value of %sysfunc(putn(&amp;amp;x,datetime25.6))";
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but if you are not planning to use this macro variable in titles or labels, do not format it. This is so important, I am going to say this three more times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you are not planning to use this macro variable in titles or labels, do not format it&lt;/P&gt;
&lt;P&gt;if you are not planning to use this macro variable in titles or labels, do not format it&lt;/P&gt;
&lt;P&gt;if you are not planning to use this macro variable in titles or labels, do not format it&lt;/P&gt;
&lt;P&gt;if you are not planning to use this macro variable in titles or labels, do not format it&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 13:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616902#M180695</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-13T13:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: convert macro variable to datetime</title>
      <link>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616911#M180700</link>
      <description>&lt;P&gt;What do you plan to do with it?&amp;nbsp; Are you going to us it to generate code?&amp;nbsp; If so the way to specify a datetime constant in code is to quote a string that the DATETIME informat can read and suffix the quoted string with DT (for DateTime).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let x=01JAN2020:00:00:00:447;
data want;
  set have ;
  where mydatetime_var &amp;lt; "&amp;amp;x"dt ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 14:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/convert-macro-variable-to-datetime/m-p/616911#M180700</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-01-13T14:01:51Z</dc:date>
    </item>
  </channel>
</rss>

