I'm working on this macro (see below) and this statement is not resolving : %if (&var_len > &&max&i) %then %let max&i=&var_len; and the error that is returned is: ERROR: Required operator not found in expression: (&var_len > &&max&i) ERROR: The macro PRCS_FREQ will stop executing
Does anyone have any idea on how I can improve this macro and to get this statement to resolve?
Macro:
%macro prcs_freq;
%do i=1 %to &n_of_var;
%global end&i f_line_count&i f_var&i;
%let max&i=1;
%let k=%eval(&i+1);
%if (&i < &n_of_var) %then %let end&i=%eval(&&cum&k-1);
%else %let end&i=&n_of_line;
%let f=%eval(&&cum&i+1); /* line number for "Frequency" */
%let freq_pos&i=%index(%bquote(&&line&f),Frequency); /* column position of "Frequency" */
%let f_var&i=%upcase(%scan(%bquote(&&line&f),1,%str( )));
%let var_len=%length(&&f_var&i);
%let max&i=&var_len;
%global &&f_var&i;
%let &&f_var&i=&i; /* for Frequency */
%do j=&f+2 %to &&end&i;
%let var_len=%length(%substr(%bquote(&&line&j),1,&&freq_pos&i-1));
%if (&var_len > &&max&i) %then %let max&i=&var_len;
%put *** f=&f i=&i j=&j var_len=&var_len freq_pos&i=&&freq_pos&i
max&i=&&max&i f_var&i=&&f_var&i;
%end; /* %do j= */
%let f_line_count&i=%eval(&&end&i-&&cum&i+1);
%end; /* %do i= */
data _null_;
%do i=1 %to &n_of_var;
file "&wk_dir/&&f_var&i...txt";
%do j=&&cum&i %to &&end&i;
put "%substr(%bquote(&&line&j),1,&&max&i+5)%substr(%bquote (&&line&j),&&freq_pos&i)";
%end;
%end;
run;
/* test */
%put =====;
%put ===== Frequency;
%put =====;
%do i=1 %to &n_of_var;
%put f_var&i=&&f_var&i cum&i=&&cum&i end&i=&&end&i f_line_count&i=&&f_line_count&i &&f_var&i=&&&&&&f_var&i;
%end;
%mend prcs_freq;
%put var_len = "&var_len" max_i = "&&max&i";? This would probably make it easier to debug. - user667489%evalin this:%do j=&f+2 %to &&end&i;A%evalis required around&f+2. - mjsqu