Can anyone please explain what each element in the line in blue is doing? In particular, what is the comma in the "%then," doing and why does the %to value seem to need to match the value in "&count ne #" or else an error will result? Thanks in advance! data purchases; input id year order; datalines; 123 2018 1 124 2018 1 124 2018 2 125 2018 1 125 2018 2 125 2018 3 ; %macro transpose; proc sql; create table trans_purchases as select distinct id, year, %do count = 1 %to 3; case when order = &count. then 1 else 0 end as order&count. %if (&count. ne 3) %then,; %end; from purchases; quit; %mend; %transpose;
... View more