<?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: ERROR: More positional parameters found than defined. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447468#M112418</link>
    <description>&lt;P&gt;First off you used a macro variable in the macro definition for the&amp;nbsp;parameter and defined it as a KEYWORD parameter. Keyword parameters must be used with the = in the actual macro call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro dummy(keyword=);&lt;/P&gt;
&lt;P&gt;definition requires use as&lt;/P&gt;
&lt;P&gt;%dummy(keyword= some value);&lt;/P&gt;
&lt;P&gt;when you use&lt;/P&gt;
&lt;P&gt;%dummy(somevalue); then the parameter is assumed to be positional, meaning the first encountered value is the value for the first parameter in the definition. You did not define any positional parameters so that is the cause of the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However without knowing the value &amp;amp;date_1 at the time you compiled the macro we do not even know the proper name of the macro variable to use.&lt;/P&gt;
&lt;P&gt;Where does the value from &amp;amp;date_process come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the purpose of this macro is to create a new variable as a SAS date value from a string variable that has a content like 03212018 then perhaps&lt;/P&gt;
&lt;PRE&gt;%macro change_date_format(datestringvar);
&amp;amp;datestringvar.new = input(&amp;amp;datestringvar,mmddyy8.);
format &amp;amp;datestringvar.new date9.;
%mend;&lt;/PRE&gt;
&lt;P&gt;Then the call you used would be correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: automatically adding the same string to an existing variable name to an existing variable may have issues with the new variable name if you have some variable names that approach the 32 character limit. Example:&lt;/P&gt;
&lt;P&gt;date_for_processing_sales_report is already 32 characters long. Adding "new" to the end would exceed the length of a valid variable.&lt;/P&gt;
&lt;P&gt;An exercise for the interested reader is the test the result of &amp;amp;datestringvar.new as a valid variable name and making and adjustment if too long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note the use of an INFORMAT specifically designed to read dates in mmddyy format like 03212018. This informat will also read "032118",&amp;nbsp;"03&amp;nbsp;21 18" or "03/21/18" as March 21, 2018.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Mar 2018 16:11:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-21T16:11:41Z</dc:date>
    <item>
      <title>ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447455#M112411</link>
      <description>&lt;P&gt;%macro change_date_format(&amp;amp;Date_1=);&lt;BR /&gt;%let Date_1=&amp;amp;date_process.;&lt;BR /&gt;format &amp;amp;Date_1._New date9.;&lt;BR /&gt;&amp;amp;Date_1._New=mdy(substr(&amp;amp;Date_1.,1,2),substr(&amp;amp;Date_1.,4,2),substr(&amp;amp;Date_1.,7,4));&lt;BR /&gt;Drop &amp;amp;Date_1.;&lt;BR /&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA CMI_Repository_2;&lt;BR /&gt;SET pdata.CMI_Repository_1;&lt;/P&gt;&lt;P&gt;%change_date_format(BM_LaunchInitialDate2);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;showing error:&lt;/P&gt;&lt;P&gt;ERROR: More positional parameters found than defined.&lt;/P&gt;&lt;P&gt;how should i write this.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:48:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447455#M112411</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2018-03-21T15:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447459#M112414</link>
      <description>&lt;P&gt;If you are going to write macros, you absolutely must understand these topics:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;What is a positional parameter&lt;/LI&gt;
&lt;LI&gt;What is a keyword parameter&lt;/LI&gt;
&lt;LI&gt;How do you call a macro that has been defined with positional parameters&lt;/LI&gt;
&lt;LI&gt;How do you call a macro that has been defined with keyword parameters&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Those are things you need to find in the documentation, and study.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Secondarily, your code (once it is working) would apply SUBSTR to a variable named&amp;nbsp;&lt;SPAN&gt;BM_LaunchInitialDate2.&amp;nbsp; I would hope that this is a character variable, since SUBSTR works on character strings only.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:59:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447459#M112414</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-03-21T15:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447460#M112415</link>
      <description>&lt;P&gt;You can't call macros like that from a data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to build a macro to do, that seems complicated.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This is what your macro should try to do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_new = input(date_old, mmddyy10.);
format date_new date9.;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So maybe:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro change_date_format(Date_1=);


&amp;amp;Date_1._New=input(&amp;amp;date_1, mmddyy10.);

format &amp;amp;Date_1._New date9.;
Drop &amp;amp;Date_1.;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cmi_repository;
set ..;

%change_date_format(date_1=bm_launchInitalDate2);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 15:59:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447460#M112415</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T15:59:48Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447462#M112416</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are several problems in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro change_date_format(Date_1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format &amp;amp;Date_1._New date9.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;Date_1._New=input(&amp;amp;Date_1.,mmddyy10.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; drop &amp;amp;Date_1.;&lt;/P&gt;
&lt;P&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you don't really need a macro here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA CMI_Repository_2;&lt;BR /&gt;SET pdata.CMI_Repository_1;&lt;/P&gt;
&lt;P&gt;format date1_new date2_new ... date9.;&lt;/P&gt;
&lt;P&gt;date_1_new=input(date_1,mmddyy10.);&lt;/P&gt;
&lt;P&gt;date2_new=...;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;drop date1 date2 ...;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447462#M112416</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-03-21T16:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447465#M112417</link>
      <description>&lt;P&gt;I want to use this macro whenever I find similar situations. and my date is text hence I need to do this.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447465#M112417</guid>
      <dc:creator>Srigyan</dc:creator>
      <dc:date>2018-03-21T16:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447468#M112418</link>
      <description>&lt;P&gt;First off you used a macro variable in the macro definition for the&amp;nbsp;parameter and defined it as a KEYWORD parameter. Keyword parameters must be used with the = in the actual macro call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro dummy(keyword=);&lt;/P&gt;
&lt;P&gt;definition requires use as&lt;/P&gt;
&lt;P&gt;%dummy(keyword= some value);&lt;/P&gt;
&lt;P&gt;when you use&lt;/P&gt;
&lt;P&gt;%dummy(somevalue); then the parameter is assumed to be positional, meaning the first encountered value is the value for the first parameter in the definition. You did not define any positional parameters so that is the cause of the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However without knowing the value &amp;amp;date_1 at the time you compiled the macro we do not even know the proper name of the macro variable to use.&lt;/P&gt;
&lt;P&gt;Where does the value from &amp;amp;date_process come from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the purpose of this macro is to create a new variable as a SAS date value from a string variable that has a content like 03212018 then perhaps&lt;/P&gt;
&lt;PRE&gt;%macro change_date_format(datestringvar);
&amp;amp;datestringvar.new = input(&amp;amp;datestringvar,mmddyy8.);
format &amp;amp;datestringvar.new date9.;
%mend;&lt;/PRE&gt;
&lt;P&gt;Then the call you used would be correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: automatically adding the same string to an existing variable name to an existing variable may have issues with the new variable name if you have some variable names that approach the 32 character limit. Example:&lt;/P&gt;
&lt;P&gt;date_for_processing_sales_report is already 32 characters long. Adding "new" to the end would exceed the length of a valid variable.&lt;/P&gt;
&lt;P&gt;An exercise for the interested reader is the test the result of &amp;amp;datestringvar.new as a valid variable name and making and adjustment if too long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note the use of an INFORMAT specifically designed to read dates in mmddyy format like 03212018. This informat will also read "032118",&amp;nbsp;"03&amp;nbsp;21 18" or "03/21/18" as March 21, 2018.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:11:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447468#M112418</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-21T16:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: More positional parameters found than defined.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447477#M112422</link>
      <description>&lt;P&gt;Since the creation of the new variable is just one line of code, there is no nessity to create a macro as it obfuscates the code by requiring the maintener to find the macro code to see exactly what is done.&lt;BR /&gt;Both other instruction for format definition and dropping can be factored over all variables you want to recode.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 16:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-More-positional-parameters-found-than-defined/m-p/447477#M112422</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-03-21T16:22:59Z</dc:date>
    </item>
  </channel>
</rss>

