Hi All, I have a question about how to correct the error "All positional parameters must precede keyword parameters"
Code is below, I did add %str function to the macro variable &SEG_LIST. when I call the macro FUNC_ALLSEG, but it didn't work.
What I want to do is very straightforward. I have a macro variable SEGMENT_LIST, which stores a list of segments,
then for each segment, I use another macro FUNC1 to generate desirable results for that segment.
But still, I got error msg stated in the title line. Any ideas or thoughts are greatly appreciated!
%MACRO FUNC_ALLSEG( SEGMENT_LIST = );
%let segnum = %sysfunc(countw(&SEGMENT_LIST,%STR(,)));
%DO I=1 %TO &SEGNUM.;
%FUNC1(base = CX.BASEDATA, segment = %SCAN("&SEGMENT_LIST.",&I,"," )
%END;
%MEND;
%FUNC_ALLSEG( SEGMENT_LIST=%STR(&SEG_LIST.))
@changxuosu wrote:
Hi All, I have a question about how to correct the error "All positional parameters must precede keyword parameters"
Code is below, I did add %str function to the macro variable &SEG_LIST. when I call the macro FUNC_ALLSEG, but it didn't work.
What I want to do is very straightforward. I have a macro variable SEGMENT_LIST, which stores a list of segments,
then for each segment, I use another macro FUNC1 to generate desirable results for that segment.
But still, I got error msg stated in the title line. Any ideas or thoughts are greatly appreciated!
%MACRO FUNC_ALLSEG( SEGMENT_LIST = );
%let segnum = %sysfunc(countw(&SEGMENT_LIST,%STR(,)));
%DO I=1 %TO &SEGNUM.;
%FUNC1(base = CX.BASEDATA, segment = %SCAN("&SEGMENT_LIST.",&I,"," )
%END;
%MEND;
%FUNC_ALLSEG( SEGMENT_LIST=%STR(&SEG_LIST.))
Does your &SEG_LIST variable contain commas? If so, why? In many cases you can use space separated lists. Countw and Scan will both use spaces for delimiters. If your individual segment values contain spaces and that is why you are using a comma then use a different character instead (update your countw and %scan to use the same). The comma is the delimeter for parameters of a macro call. Using a different character would remove that error.
see if this works
%MACRO FUNC_ALLSEG( SEGMENT_LIST = );
%let segnum = %sysfunc(countw(&SEGMENT_LIST,%STR(,)));
%DO I=1 %TO &SEGNUM.;
%FUNC1(base = CX.BASEDATA, segment = %SCAN(%superq(SEGMENT_LIST),&I,%str(,) )
%END;
%MEND;
%FUNC_ALLSEG( SEGMENT_LIST=%STR(&SEG_LIST.))
Thanks a lot for your comments!
@changxuosu wrote:
Hi All, I have a question about how to correct the error "All positional parameters must precede keyword parameters"
Code is below, I did add %str function to the macro variable &SEG_LIST. when I call the macro FUNC_ALLSEG, but it didn't work.
What I want to do is very straightforward. I have a macro variable SEGMENT_LIST, which stores a list of segments,
then for each segment, I use another macro FUNC1 to generate desirable results for that segment.
But still, I got error msg stated in the title line. Any ideas or thoughts are greatly appreciated!
%MACRO FUNC_ALLSEG( SEGMENT_LIST = );
%let segnum = %sysfunc(countw(&SEGMENT_LIST,%STR(,)));
%DO I=1 %TO &SEGNUM.;
%FUNC1(base = CX.BASEDATA, segment = %SCAN("&SEGMENT_LIST.",&I,"," )
%END;
%MEND;
%FUNC_ALLSEG( SEGMENT_LIST=%STR(&SEG_LIST.))
Does your &SEG_LIST variable contain commas? If so, why? In many cases you can use space separated lists. Countw and Scan will both use spaces for delimiters. If your individual segment values contain spaces and that is why you are using a comma then use a different character instead (update your countw and %scan to use the same). The comma is the delimeter for parameters of a macro call. Using a different character would remove that error.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.