<?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: Converting Macro Variable Holding a Date to a Date Format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949860#M371519</link>
    <description>&lt;P&gt;The %SYSFUNC() macro function allows you to specify the format to use when converting the value generated by the function it is calling into text to be passed back.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024),date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your mistake was treating the digits string representing the integer value SAS uses for 15AUG2014 as if it was in YYYY-MM-DD style by trying to read it with the YYMMDD10. informat.&amp;nbsp; If you did want to use the PUTN() format to format a date value there is no need to change the integer value into some other representation.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024));
%let cutdtc = %sysfunc(putN(&amp;amp;cutdt, date9.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you do have your macro variable in DATE9 style you can easily use it in places where you need an actual date value by using it to generate a date literal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024),date9.);
title "Data before &amp;amp;cutdt";
proc print data=have;
  where date &amp;lt; "&amp;amp;cutdt"d ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Nov 2024 17:48:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-11-04T17:48:49Z</dc:date>
    <item>
      <title>Converting Macro Variable Holding a Date to a Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949859#M371518</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am creating a macro variable that holds a date, and I want to have it display as a date9 format to be used in a title.&amp;nbsp; My code is:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%global cutdt ;&lt;BR /&gt;%global cutdtc;&lt;BR /&gt;%let cutdt = %sysfunc(mdy(08,15,2024));&lt;BR /&gt;%let cutdtc = %sysfunc(inputn(&amp;amp;cutdt, yymmdd10.), date9.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, my log gives me the following messages:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;5033 %global cutdt ;&lt;BR /&gt;5034 %global cutdtc;&lt;BR /&gt;5035 %let cutdt = %sysfunc(mdy(08,15,2024));&lt;BR /&gt;5036 %let cutdtc = %sysfunc(inputn(&amp;amp;cutdt, yymmdd10.), date9.);&lt;BR /&gt;WARNING: Argument 1 to function INPUTN referenced by the %SYSFUNC or %QSYSFUNC macro function is&lt;BR /&gt;out of range.&lt;BR /&gt;NOTE: Mathematical operations could not be performed during %SYSFUNC function execution. The&lt;BR /&gt;result of the operations have been set to a missing value.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Can anyone help me troubleshoot my issue in line 5036?&amp;nbsp; I appreciate any help!&amp;nbsp; Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 17:41:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949859#M371518</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2024-11-04T17:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Variable Holding a Date to a Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949860#M371519</link>
      <description>&lt;P&gt;The %SYSFUNC() macro function allows you to specify the format to use when converting the value generated by the function it is calling into text to be passed back.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024),date9.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your mistake was treating the digits string representing the integer value SAS uses for 15AUG2014 as if it was in YYYY-MM-DD style by trying to read it with the YYMMDD10. informat.&amp;nbsp; If you did want to use the PUTN() format to format a date value there is no need to change the integer value into some other representation.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024));
%let cutdtc = %sysfunc(putN(&amp;amp;cutdt, date9.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that if you do have your macro variable in DATE9 style you can easily use it in places where you need an actual date value by using it to generate a date literal.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cutdt = %sysfunc(mdy(08,15,2024),date9.);
title "Data before &amp;amp;cutdt";
proc print data=have;
  where date &amp;lt; "&amp;amp;cutdt"d ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 17:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949860#M371519</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-11-04T17:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Macro Variable Holding a Date to a Date Format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949868#M371520</link>
      <description>&lt;P&gt;Thank you, Tom!&amp;nbsp; That was a wonderful and clear explanation! I have learned something super useful today.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 19:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-Macro-Variable-Holding-a-Date-to-a-Date-Format/m-p/949868#M371520</guid>
      <dc:creator>biglerc</dc:creator>
      <dc:date>2024-11-04T19:06:59Z</dc:date>
    </item>
  </channel>
</rss>

