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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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