I am stumped with a very simple do loop problem. For reasons unknown, the loop logic is ignoring the equals sign I'm using so that the output is not what I need. This works: data work.retail; input year:32. quarter:32. sales:32.; datalines; 2007 1 921266 2007 2 1013371 2007 3 1000151 2007 4 1060394 2008 1 950268 2008 2 1028016 2008 3 999824 2008 4 957207 ;;;; run; data work.retail2; set work.retail; if quarter = 1 then do; d1 = 1; end; else do; d1 = 0; end; if quarter = 2 then do; d2 = 1; end; else do; d2 = 0; end; if quarter = 3 then do; d3 = 1; end; else do; d3 = 0; end; run; /* But this does not work */ %macro MakeRetail2; data work.retail2; set work.retail; %do i =1 %to 3; %if quarter = &i %then %do; d&i = 1; %end; %else %do; d&i = 0; %end; * end else-do; %end; * end do-loop *; output; run; %mend MakeRetail2; %MakeRetail2 /* Any guidance would be appreciated */
... View more