Hey, I am a beginner in SAS so I appreciate any help.
I want to iterate the following code:
data sampledata;
set sampledata;
if variable_i = j then indicator_variable_i = 1;
else indicator_variable_i = 0;
run;
and I want to iterate it over i and j. "other_variable" does not exist before so it should be a new variable like an indicator.
I tried using my macro, but It somewhat not working 😕
%macro zeroone(variable, indicator_variable);
data sampledata;
set sampledata;
%do i=0 %to 6;
&indicator_variable&i = 0;
%do j=1 %to 3;
%If &variable&j = &i %then %do;
&indicator_variable&i = 1;
%end;
%end;
%end;
run;
%mend zeroone;
Does anyone have any idea for me? 🙂
Thanks in advance 🙂
... View more