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