11-26-2014 07:01 AM
This isn't working for me. I think the problem is with the "do loop" since when i put the dates into the macro manually it works.
format live&date. best12.;
live&date. = 0
if datchd < &date then do;
if ddtermd > &date then live&date. = 1;
if ddtermd = 0 then live&date. = 1;
%let start = 20010101
%let end = 20100101
do i = &start to &end by 10000;
11-26-2014 07:13 AM
I hardcodes the code in this forum so left out the semi colons in error. Basically the code should create 11 columns live20010101, live20020101, ..., and so on and they're all populated with 0's unless the dates satisfy the conditions in the macro, uin which case they are populated with 1. The 'do.. by' loop is not working since not even the fields live20010101 ... are being created.
11-26-2014 07:56 AM
The do loop is part of the data step and executed at runtime of the data step.
%macro1(i) is executed by the macro processor BEFORE the data step is compiled and executed, with "i" as parameter.
Therefore you end up with the following code in the do loop:
format livei best12.;
livei = 0
if datchd < i then do;
if ddtermd > i then livei = 1;
if ddtermd = 0 then livei = 1;
Keep in mind that the macro processor is a PREprocessor.