Execute command stored in variable

  • Follow


Hi,

I wrote a macro to iterate over words in a string:

%MACRO forallStr(str,command,sep=' ');
%LET _i=1;
%DO %WHILE (%QSCAN(&str,&_i,&sep) NE);
  %LET _x=%QSCAN(&str,&_i,&sep);
  DATA _NULL_;
    CALL EXECUTE("&command");
  RUN;
  %LET _i=%EVAL(&_i+1);
  %END;
%MEND;

The only problem now is that I cannot nest this in another datastep
(due to the DATA step in the macro). Just writing
&command;
instead of the DATA step here didn't work. I assume the macro
processor doesn't look twice.

Is there a way to make it work so that I can write for example
DATA d;
  %forallStr('a b c',%NRSTR(var="&_x"; OUTPUT));
RUN;
??
0
Reply A 7/8/2010 8:33:33 AM


0 Replies
230 Views

(page loaded in 0.023 seconds)

Similiar Articles:













6/25/2012 10:28:51 AM


Reply: