<?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: finding error in SAS macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905789#M357712</link>
    <description>&lt;P&gt;Here's a situation that will cause trouble with the INPUT function and macros.&amp;nbsp; I'm not sure if you would get the error message that you received or not, but here it is anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using %SYSFUNC, you cannot use it to call the INPUT function.&amp;nbsp; You would have to switch to INPUTC or INPUTN instead.&amp;nbsp; That's fairly easy to check in your code, to see if %SYSFUNC is being used to call the INPUT function, along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let m = %sysfunc(input(.......&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 02 Dec 2023 02:11:11 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2023-12-02T02:11:11Z</dc:date>
    <item>
      <title>finding error in SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905494#M357652</link>
      <description>&lt;P&gt;I get an error like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: Invalid argument to function INPUT at line 110 column 167.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, since it is in a macro, I don't have line numbers in the log to find the exact location. How do I find which line the error is occurring?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 02:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905494#M357652</guid>
      <dc:creator>axescot78</dc:creator>
      <dc:date>2023-12-01T02:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: finding error in SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905500#M357653</link>
      <description>&lt;P&gt;Turn on the SAS MPRINT option and rerun your macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The SAS log should then show where the error is.&lt;/P&gt;
&lt;P&gt;Also search through your macro to find where the SAS function INPUT is used.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 02:20:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905500#M357653</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-12-01T02:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: finding error in SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905511#M357655</link>
      <description>&lt;P&gt;LINE and COLUMN really don't translate very well with macro code.&lt;/P&gt;
&lt;P&gt;If you only have a couple of INPUT() function calls then just just the data for all of them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could turn on the MPRINT option and copy the generated code from the log and run that step again as plain old SAS code and then you will get a real line and column number to help you find the mistake.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also re-write the code to check for issues itself.&lt;/P&gt;
&lt;P&gt;So if you have, for example something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;newvar = input(oldvar,yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could try making sure that the value is valid for that informat first.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(oldvar) and missing(input(oldvar,??yymmdd10.) then 
  put 'WARNING: Value of ' oldvar= 'is not valid for informat YYMMDD10.';
else newvar = input(oldvar,yymmdd10.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2023 03:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905511#M357655</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-12-01T03:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding error in SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905519#M357658</link>
      <description>&lt;P&gt;The "best practice" approach for writing macros is to first write the code for a single use case without macro and fully debug it. Only then make the code dynamic via a macro.&lt;/P&gt;
&lt;P&gt;Following this approach normally lets you fix issues like the one you encounter before you have to deal with anything macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you've got it already in a macro then try if options mprint and eventually spool create enough log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test();
  data _null_;
    xx=input('A',date.);
  run;
%mend;

options mprint spool;
%test();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it's really bad then you could also use the mfile option. This lets you capture the macro generated SAS code and then execute this code separately with everything macro already resolved.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename mprint temp;
options mprint mfile;
%test();

%include mprint /source2;
options nomfile;
filename mprint clear;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;32         %include mprint /source2;
NOTE: %INCLUDE (level 1) file MPRINT is file 
      ....\SAS Temporary Files\_TD20848_******_\#LN00166.
33        +data _null_;
34        +xx=input('A',date.);
35        +run;

NOTE: Invalid argument to function INPUT at line 34 column 4.
xx=. _ERROR_=1 _N_=1&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2023 05:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905519#M357658</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-12-01T05:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: finding error in SAS macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905789#M357712</link>
      <description>&lt;P&gt;Here's a situation that will cause trouble with the INPUT function and macros.&amp;nbsp; I'm not sure if you would get the error message that you received or not, but here it is anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using %SYSFUNC, you cannot use it to call the INPUT function.&amp;nbsp; You would have to switch to INPUTC or INPUTN instead.&amp;nbsp; That's fairly easy to check in your code, to see if %SYSFUNC is being used to call the INPUT function, along these lines:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let m = %sysfunc(input(.......&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Dec 2023 02:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/finding-error-in-SAS-macro/m-p/905789#M357712</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2023-12-02T02:11:11Z</dc:date>
    </item>
  </channel>
</rss>

