Hi,
I am running a code each month. In which I have to calculate monthly growth by taking base value as of last quarter. Here is the dummy code -
/*April 2015*/
if xyz_Date >= '01april2015:00:00:00'dt then do; net_growth = sum(bal_04_2015,-bal_03_2015); end; else do; net_growth = sum(bal_04_2015,-bal_03_2015); end;
/*May 2015*/
if xyz_Date >= '01may2015:00:00:00'dt then do; net_growth = sum(bal_05_2015,-bal_04_2015); end;
else if xyz_Date >= '01apr2015:00:00:00'dt then do; net_growth = sum(bal_05_2015,-bal_03_2015); end; else do; net_growth = sum(bal_05_2015,-bal_03_2015); end;
/*June 2015*/
if xyz_Date >= '01jun2015:00:00:00'dt then do; net_growth = sum(bal_06_2015,-bal_05_2015); end; else if xyz_Date >= '01may2015:00:00:00'dt then do; net_growth = sum(bal_06_2015,-bal_04_2015); end; else if xyz_Date >= '01apr2015:00:00:00'dt then do; net_growth = sum(bal_06_2015,-bal_03_2015); end; else do; net_growth = sum(bal_06_2015,-bal_03_2015); end;
In the above code, if the current month is April, then April section will run only, if May then May section will run only, if June then June section will run only and if July then again code will be same as April section with different variables (variables for July and June month).
How can I automate this code?
Any Idea...Looping or something else
... View more