03-06-2018 03:01 PM
I have two list of variables, they are the same metrics, but from different point of time, right now I want to calculate the difference between them, the dataset looks like this:
account fico_201701 beacon_201701 dpd_201701 fico_201712 beacon_201712 dpd_201712
I want to calculate difference between fico_201701 and fico_201712/ beacon_201701 and beacon_201712 and etc, how do I program for it?
03-06-2018 03:16 PM
Are you joining two tables into one and trying to get the difference between variables of alike ones.
Table A : account fico_201701 beacon_201701 dpd_201701
Table B : account fico_201712 beacon_201712 dpd_201712
03-06-2018 11:23 PM
03-07-2018 02:59 AM
I would start by fixing the input datasets so that they have a date-variable containing the postfix of the other variables, thus you can store the data of any time point in on dataset. For the calculation you need the data sorted by account and date, then you can use the dif-function to get the differences.
03-07-2018 09:18 AM
Maybe my eyes need to checked by a doc, but i can't see anything about having 600 vars in your starting post. Using an array with a simple loop seems to be appropriate.
data work.want; set have; by account; array vars fico beacon dpd ...; array diffs fico_diff beacon_diff dpd_diff ...; do i = 1 to dim(vars); diffs[i] = lag(vars[i]); if first.account then do; diffs[i] = 0; end; end; run;