You're misunderstanding what the macro processor does, and when it does it. If we feed var=xy and num=3 to your macro, it will do the following: &var&var_num will evaluate to xy1 xy2 xy3 respectively All these are clearly not 0, so therefore the macro processor will supply the lines perc_xy1 = xy1 / total; perc_xy2 = xy2 / total; perc_xy3 = xy3 / total; to the SAS interpreter. Anytime total equates to zero, you get a warning. The macro processor is invoked BEFORE any data step runs, and does its work without any knowledge about what happens during data step execution. It is only there to generate program text. Repeat the last sentence three times. You most probably want this in your %do loop: if total ne 0 then perc_&var&var_num = &var&var_num / total; else perc_&var&var_num = 0; This piece of code is then repeatedly supplied vor every var_num to the data step code.
... View more