You cannot replace the list with a single item and expect it to work for more than one item.
If NAME and PREFIX go together then you only need one %DO loop to cover both lists.
You have to use the same delimiter when counting how many items are in the list as you use when scanning the list. What is the delimiter for the other lists? Be specific when telling COUNT() and %SCAN() what delimiter to use.
Are you really using both single quote and ~ as delimiters in the METHOD list? Why? You appear to be using the value scanned from METHOD as part of a dataset name, so why not just use space as the delimiter? You can add the Q modifier when scanning the quoted name strings.
Try something like this:
%macro train(method=,prefix=,name=,fold=);
%local m p n f nm np nf;
%do nm=1 %to %sysfunc(countw(&method,%str( )));
%let m=%scan(&method,&nm,%str( ));
%do np=1 %to %sysfunc(countw(&prefix,%str( )));
%let p=%scan(&prefix,&np,%str( ));
%let n=%scan(&name,&np,%str( ),q);
%do nf=1 %to %sysfunc(countw(&fold,%str( )));
%let f=%scan(&fold,&nf,%str( ));
%put &=nm &=m &=np &=p &=n &=nf &=f;
proc assess
data=casuser.scored_&p._fold_eq_&f._&m. (where=(outer_k_fold ne 1))
ROCOUT=casuser.&p._fold_ne_&f._rocinfo_&m.
;
input P_target1;
target target / level=nominal event='1';
fitstat pvar=P_target0 / pevent='0';
run;
%end;
%end;
%end;
%mend train;
%train(method=mtd1, prefix=DT RF, name="Decision_Tree" "Random Forest",fold=1 2 3);
If I remove the actual SAS code so I can test the macro without your dataset I get:
554 %train(method=mtd1, prefix=DT RF, name="Decision_Tree" "Random Forest",fold=1 2 3);
NM=1 M=mtd1 NP=1 P=DT N="Decision_Tree" NF=1 F=1
NM=1 M=mtd1 NP=1 P=DT N="Decision_Tree" NF=2 F=2
NM=1 M=mtd1 NP=1 P=DT N="Decision_Tree" NF=3 F=3
NM=1 M=mtd1 NP=2 P=RF N="Random Forest" NF=1 F=1
NM=1 M=mtd1 NP=2 P=RF N="Random Forest" NF=2 F=2
NM=1 M=mtd1 NP=2 P=RF N="Random Forest" NF=3 F=3
... View more