<?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 How to debug this Macro definition error &amp;quot;Expecting a name&amp;quot; in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-this-Macro-definition-error-quot-Expecting-a-name/m-p/408572#M279485</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options MPRINT MLOGIC MERROR SYMBOLGEN;

%macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
	proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;
	 by &amp;amp;byvar;
	run;
%mend;

%srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have created a Standard macro for sorting procedure with all the possible macro keyword parameters.&lt;/P&gt;&lt;P&gt;The ERROR is at Dupout step is : Expecting a name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At scenarios where need to store duplicate values&amp;nbsp; there won't be any error because i will be passing the value for that parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But at some scenarios no need to store duplicate values. since it is keyword parameter no nee to pass value for&amp;nbsp; macro variable while calling a macro. here am getting error. it is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;224  options MPRINT MLOGIC MERROR SYMBOLGEN;
225
226  %macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
227      proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;
228       by &amp;amp;byvar;
229      run;
230  %mend;
231
232  %srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);
MLOGIC(SRT):  Beginning execution.
MLOGIC(SRT):  Parameter DSN has value sashelp.class
MLOGIC(SRT):  Parameter S_DSN has value srt_cls
MLOGIC(SRT):  Parameter BYVAR has value sex
MLOGIC(SRT):  Parameter KEY has value nodupkey
MLOGIC(SRT):  Parameter D_DSN has value
SYMBOLGEN:  Macro variable DSN resolves to sashelp.class
SYMBOLGEN:  Macro variable S_DSN resolves to srt_cls
SYMBOLGEN:  Macro variable KEY resolves to nodupkey
SYMBOLGEN:  Macro variable D_DSN resolves to
NOTE 137-205: Line generated by the invoked macro "SRT".
1      proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;      by &amp;amp;byvar;     run;
                                                              -
                                                              22
ERROR 22-322: Expecting a name.

MPRINT(SRT):   proc sort data = sashelp.class out = srt_cls nodupkey dupout = ;
SYMBOLGEN:  Macro variable BYVAR resolves to sex
MPRINT(SRT):   by sex;
MPRINT(SRT):   run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SRT_CLS may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.SRT_CLS was not replaced because this step was stopped.
WARNING: The data set WORK.NAME may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.NAME was not replaced because this step was stopped.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

MLOGIC(SRT):  Ending execution&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Oct 2017 11:24:09 GMT</pubDate>
    <dc:creator>GeethaMN</dc:creator>
    <dc:date>2017-10-30T11:24:09Z</dc:date>
    <item>
      <title>How to debug this Macro definition error "Expecting a name"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-this-Macro-definition-error-quot-Expecting-a-name/m-p/408572#M279485</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options MPRINT MLOGIC MERROR SYMBOLGEN;

%macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
	proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;
	 by &amp;amp;byvar;
	run;
%mend;

%srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have created a Standard macro for sorting procedure with all the possible macro keyword parameters.&lt;/P&gt;&lt;P&gt;The ERROR is at Dupout step is : Expecting a name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At scenarios where need to store duplicate values&amp;nbsp; there won't be any error because i will be passing the value for that parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But at some scenarios no need to store duplicate values. since it is keyword parameter no nee to pass value for&amp;nbsp; macro variable while calling a macro. here am getting error. it is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;224  options MPRINT MLOGIC MERROR SYMBOLGEN;
225
226  %macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
227      proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;
228       by &amp;amp;byvar;
229      run;
230  %mend;
231
232  %srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);
MLOGIC(SRT):  Beginning execution.
MLOGIC(SRT):  Parameter DSN has value sashelp.class
MLOGIC(SRT):  Parameter S_DSN has value srt_cls
MLOGIC(SRT):  Parameter BYVAR has value sex
MLOGIC(SRT):  Parameter KEY has value nodupkey
MLOGIC(SRT):  Parameter D_DSN has value
SYMBOLGEN:  Macro variable DSN resolves to sashelp.class
SYMBOLGEN:  Macro variable S_DSN resolves to srt_cls
SYMBOLGEN:  Macro variable KEY resolves to nodupkey
SYMBOLGEN:  Macro variable D_DSN resolves to
NOTE 137-205: Line generated by the invoked macro "SRT".
1      proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key dupout = &amp;amp;d_dsn;      by &amp;amp;byvar;     run;
                                                              -
                                                              22
ERROR 22-322: Expecting a name.

MPRINT(SRT):   proc sort data = sashelp.class out = srt_cls nodupkey dupout = ;
SYMBOLGEN:  Macro variable BYVAR resolves to sex
MPRINT(SRT):   by sex;
MPRINT(SRT):   run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.SRT_CLS may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.SRT_CLS was not replaced because this step was stopped.
WARNING: The data set WORK.NAME may be incomplete.  When this step was stopped there were 0
         observations and 0 variables.
WARNING: Data set WORK.NAME was not replaced because this step was stopped.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

MLOGIC(SRT):  Ending execution&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Oct 2017 11:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-this-Macro-definition-error-quot-Expecting-a-name/m-p/408572#M279485</guid>
      <dc:creator>GeethaMN</dc:creator>
      <dc:date>2017-10-30T11:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to debug this Macro definition error "Expecting a name"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-debug-this-Macro-definition-error-quot-Expecting-a-name/m-p/408579#M279486</link>
      <description>&lt;P&gt;Well, to answer your question;&lt;/P&gt;
&lt;PRE&gt;options MPRINT MLOGIC MERROR SYMBOLGEN;

%macro srt(dsn=,s_dsn=,key=,byvar=,d_dsn=);
	proc sort data = &amp;amp;dsn out = &amp;amp;s_dsn &amp;amp;key 
          %if &amp;amp;d_dsn. ne  %then %do;
            dupout = &amp;amp;d_dsn
          %end
         ;
	 by &amp;amp;byvar;
	run;
%mend;

%srt(dsn=sashelp.class,s_dsn = srt_cls,byvar = sex,key = nodupkey);&lt;/PRE&gt;
&lt;P&gt;However to add, why would you want to create a standard sort macro?&amp;nbsp; You are just obfuscating what is a simple base SAS procedure for no apparent reason.&amp;nbsp; Let me explain, all SAS programmers know how to write a proc sort step, now along comes the macro varient which wraps up some code and hides it behind a %srt call.&amp;nbsp; What does that mean, does it sort it ascending or descending, what about indexes, does it do anything else.&amp;nbsp; You have taken something simple and well known and obfuscated it.&amp;nbsp; Macro is&amp;nbsp;&lt;U&gt;&lt;STRONG&gt;not&lt;/STRONG&gt;&lt;/U&gt; a replacement for Base SAS,&amp;nbsp;and half the skill of creating an efficient standard macro library is knowing where to use macro and where not.&lt;/P&gt;
&lt;P&gt;Also, please put the dot after macro variables, whilst not always necessary it is a good idea to always do it (and it will highlight in editor).&lt;/P&gt;</description>
      <pubDate>Mon, 30 Oct 2017 11:33:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-debug-this-Macro-definition-error-quot-Expecting-a-name/m-p/408579#M279486</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-30T11:33:11Z</dc:date>
    </item>
  </channel>
</rss>

