sas - Create function of two variables with do loop -
i calculate variables ar_1 ar_99 based upon formula
ar_(i) = 0.5*(adm_(i) + adm_(j))
where j=i+1 (adm_1 adm_100 exist in dataset). using following loop error sas not recognise variable j.
%macro do_loop; data testdo; set popn99; %do = 1 %to 99; &j.=&i.+1; ar_&i. = 0.5 * (adm_&i. + adm_&j.); %end; run; %mend do_loop; %do_loop;
try:
%macro do_loop; data testdo; set popn99; %do = 1 %to 99; ar_&i. = 0.5 * (adm_&i. + adm_%eval(&i.+1) ); %end; run; %mend do_loop; %do_loop;
remember sas macro code writes text only. following assignment, should have resolved (which wouldn't "j" macro variable didn't exist), have assigned value "column".
&j.=&i.+1;
that not have been re-used macro variable in subsequent step.
to generalise - sas macro language writes sas programs (base code) subsequently execute produce results..
Comments
Post a Comment