I have data with many array variables. I need to check if the values of the variables in the array meet certain conditions. I am not sure how this can be done using a macro. eg: data ds1; set ds1; array a1[*] a1_1- a1_100; array a2[*] a2_1 -a2_100; ... array a4[*] a4_1-a4_100; run; I would like to check if any of the a1, a2,...a10 is empty or negative. and for some >1...If so then the macro would stop and give error. I am using the following in a macro: %macro test(dsin=ds1); data &dsin1; set &dsin1; stop_a1=0; stop_a2=0; stop_a3=0; stop_a4=0; stop_var=0; %do i=1 %to 100; if ((a1_&i=.) or (a1_&i <0) or (a1_&i>1)) then stop_a1=1; if ((a2_&i=.) or (a2_&i <0)) then stop_a2=1; if ((a3_&i=.) or (a3_&i <0) or (a3_&i>1)) then stop_a3=1; if ((a4_&i=.) or (a4_&i <0) or (a4_&i>1)) then stop_a4=1; ; call symput("error_a1", stop_a1); call symput("error_a2", stop_a2); call symput("error_a3", stop_a3); call symput("error_a4", stop_4); %end; if ((discount_rate)=. or (discount_rate<0) or (discount_rate>1)) then stop_var=1; call symput("error_var", stop_var); run; %if error_a1=1 %then %do; %put Error: a1 vector error; %end; %if error_a2=1 %then %do; %put Error: a2 vector error; %end; %if error_a3=1 %then %do; %put Error:a3 vector error; %end; %if error_a4=1 %then %do; %put Error: a4 vector error; %end; %if error_var=1 %then %do; %put Error: Check the data; %end; %mend; I know there is error in the data set sdin1, but it is not giving me the error message. I am not sure what I am doing wrong here. Also any other better way to do this? Many thanks!
... View more