Hi, I am new to SAS and need some help. I have a dataset with the following data: Company number, year, month, Revenue. File attached. I was able to calculate the change in revenue for current month compared to previous month using the below code data mylibrary.RevenueYOYGrowth;
set mylibrary.chug_test;
by company_number yr;
lyr1 = lag1(revenue);
if first.yr then count=0;else count+1;
if count ge 1 then growth1yr=100*(revenue-lyr1)/lyr1;
run; The above code works perfectly if the company has data for all the months in year. Requirement is, if the company has partial revenue in one year, the change in revenue should only be calculated for those months. So if a company has revenue for months say September 2017, October 2017, November 2017, December 2017, then the revenue should be calculated only for those months in 2018 also. Basically, (sum(september2017+october2017+november2017+december2017)-sum(september2018+october2018+november2018+december2018))/sum(september2018+october2018+november2018+december2018) Excel attached shows sample data for both scenarios. I am needing help for the scenario in yellow. Please find attached Appreciate a quick response! Thank you!
... View more