02-17-2012 07:15 AM
I am new to SAS and came across some SAS code.It is working fine. But feel difficulty in understanding the flow of SAS code. Could any one explain the flow of this %DO,IF and %DO %WHILE loops....how and when IF condition is getting executed with this %DO %WHILE and Macro variables?
%do trig_i=1 %to &trig_count.;
if 1 eq 1
%do %while(&trig ne %str());
02-17-2012 08:41 AM
The macro logic allows you to generate SAS code. In this case the macro logic is generating IF/THEN/DO/END blocks of statements. It does this &TRIG_COUNT times.
To see if it will really work you need to see the rest of the macro definition and also the DATA step that these IF statements will be used within.
02-17-2012 10:08 AM
One way to see what is going on is to execute the code with OPTIONS MPRINT SYMBOLGEN; in the code.
The log will then show what the macro variables are being evaluated to (SYMBOLGEN) and then what entire lines of generated code looks like (MPRINT). The log will also display the name of the macro executing which is helpful if you have multiple macros in your program.
Turn the options off with OPTIONS NOMPRINT NOSYMBOLGEN;