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

Hi,

 

I am trying to implementing a treeboost procedure for my dataset. 

modevals is the dataset that consists of the variables that I want to use for the treeboost.

ParamList consists of the list of variable names.

I am getting the error "The %DO statement is not valid in open code" when I run the below code.

 

PROC TREEBOOST data=modelvals
CATEGORICALBINS=6
INTERVALBINS=20
EXHAUSTIVE=100
INTERVALDECIMALS= MAX
MAXDEPTH = 3
MAXBRANCH = 5
leafsize=15
Iterations=2000
Mincatsize=10
seed=n
TRAINPROPORTION = 0.5
SHRINKAGE=0.1
SPLITSIZE=30;

%let i = 1;
%let token = %scan(&ParamList,&i);

%do %while(%length(&token));
          INPUT &TOKEN/MISSING=BIGBRANCH MAXBRANCHES=2;
          %let i = %eval(&i+1);
          %let token = %scan(&ParamList,&i);
%end;
Target TARGET_VARIABLE /level=binary;
SUBSERIES LONGEST;
SAVE FIT=X._fit MODEL=ABC.X._mdl RULES=ABC.X._rul nodestats=ABC.X._nod IMPORTANCE=imp;
run;

 

Please help.

 

Regards,

Bond

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

%do %while is only allowed in a macro. You need to create a macro and execute it (partial code):

SPLITSIZE=30;
%macro mymac;
%let i = 1;
%let token = %scan(&ParamList,&i);
%do %while(%length(&token));
          INPUT &TOKEN/MISSING=BIGBRANCH MAXBRANCHES=2;
          %let i = %eval(&i+1);
          %let token = %scan(&ParamList,&i);
%end;
%mend;
%mymac
Target TARGET_VARIABLE /level=binary;

View solution in original post

1 REPLY 1
Kurt_Bremser
Super User

%do %while is only allowed in a macro. You need to create a macro and execute it (partial code):

SPLITSIZE=30;
%macro mymac;
%let i = 1;
%let token = %scan(&ParamList,&i);
%do %while(%length(&token));
          INPUT &TOKEN/MISSING=BIGBRANCH MAXBRANCHES=2;
          %let i = %eval(&i+1);
          %let token = %scan(&ParamList,&i);
%end;
%mend;
%mymac
Target TARGET_VARIABLE /level=binary;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 1 reply
  • 5512 views
  • 0 likes
  • 2 in conversation