我正在学习 SAS 并编写这个宏:
%macro firstMacro(mvLO, OLO);
%local Count;
%local Wordy;
%local Resty;
%let Resty = '';
%let Count = %sysfunc( count( &OLO, %str( ) ) );
%let Wordy = %sysfunc( scan(&OLO, 1 ,%str( ) ) );
%let Wordy = "&Wordy";
%let Resty = &Wordy;
%put &Resty;
/*strange behavior here*/
%DO I=2 %TO &Count+1;
%let Wordy = %sysfunc(scan(&OLO, &I ,%str( ) ));
%let Wordy = "&Wordy";
%put Wordy is;
%put &Wordy;
%let Resty = %sysfunc(cats(&Resty, %str(,), &Wordy));
%put &Resty;
%END;
%put FINAL OUT;
%put &Resty;
%mend firstMacro;
并称它为:
%firstMacro(mvLO=WORK, OLO=field_1 field_2 field_3);
并查看此输出:
FINAL OUT
"field_1""field_2","field_3
所以,我问SAS:你为什么在和,
之间吃我的逗号()?field_1
field_2