BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
changxuosu
Quartz | Level 8

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.))

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@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.

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

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.))
ballardw
Super User

@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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 4611 views
  • 2 likes
  • 3 in conversation