<?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: Change format of date in macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926853#M364765</link>
    <description>&lt;P&gt;It's easier to store dates a SAS date values.&amp;nbsp; But with your date as is, you need to make a few changes:&lt;/P&gt;
&lt;P&gt;1. Use INPUTN not INPUTC&lt;/P&gt;
&lt;P&gt;2. No quotations marks&lt;/P&gt;
&lt;P&gt;3. Use %bquote to mask the comma in your value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like:&lt;/P&gt;
&lt;PRE&gt;1    %let d1 = February 24, 2003;
2    %let d2 = %sysfunc(inputn(%bquote(&amp;amp;d1), nldate200.), date9.);
3    %put &amp;amp;d2;
24FEB2003
&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 May 2024 21:18:12 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-05-02T21:18:12Z</dc:date>
    <item>
      <title>Change format of date in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926852#M364764</link>
      <description>&lt;P&gt;Hello everyone:&lt;/P&gt;&lt;P&gt;I'm writing a task and one of the objects (daterange) returns a couple of dates to two macro variables. I can read these two variables properly to a table with the following code:&lt;/P&gt;&lt;PRE&gt;options locale=English_UnitedStates;
%let d1 = February 24, 2003;
data test;
	dd = input("&amp;amp;d1", nldate200.);
run;&lt;/PRE&gt;&lt;P&gt;But I can't read read the date in the macro variable and save it in another one with the format I need (date9. would ideal). I have tried the following, but it doesn't work.&lt;/P&gt;&lt;PRE&gt;options locale=English_UnitedStates;
%let d1 = February 24, 2003;
%let d2 = %sysfunc(inputn("&amp;amp;d1", nldate200.), date9.);
%put &amp;amp;d2;&lt;/PRE&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2024 21:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926852#M364764</guid>
      <dc:creator>JordiGC</dc:creator>
      <dc:date>2024-05-02T21:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: Change format of date in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926853#M364765</link>
      <description>&lt;P&gt;It's easier to store dates a SAS date values.&amp;nbsp; But with your date as is, you need to make a few changes:&lt;/P&gt;
&lt;P&gt;1. Use INPUTN not INPUTC&lt;/P&gt;
&lt;P&gt;2. No quotations marks&lt;/P&gt;
&lt;P&gt;3. Use %bquote to mask the comma in your value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like:&lt;/P&gt;
&lt;PRE&gt;1    %let d1 = February 24, 2003;
2    %let d2 = %sysfunc(inputn(%bquote(&amp;amp;d1), nldate200.), date9.);
3    %put &amp;amp;d2;
24FEB2003
&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 May 2024 21:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926853#M364765</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-05-02T21:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Change format of date in macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926873#M364778</link>
      <description>&lt;P&gt;Thank you Quentin. I just had to add the following line before the line you sent to me because I'm execting this script in Spain and the long format is different here:&lt;/P&gt;&lt;PRE&gt;options locale=English_UnitedStates;&lt;/PRE&gt;&lt;P&gt;I tried the same code but with %nrstr, but it didn't work. Yours works perfectly fine.&lt;/P&gt;&lt;P&gt;Thanh you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2024 08:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-format-of-date-in-macro-variable/m-p/926873#M364778</guid>
      <dc:creator>JordiGC</dc:creator>
      <dc:date>2024-05-03T08:01:17Z</dc:date>
    </item>
  </channel>
</rss>

