I have a data set like this;
DATA work.faminc;
INPUT famid faminc1-faminc12 ;
CARDS;
1 3281 3413 3114 2500 2700 3500 3114 3319 3514 1282 2434 2818
2 4042 3084 3108 3150 3800 3100 1531 2914 3819 4124 4274 4471
3 6015 6123 6113 6100 6100 6200 6186 6132 3123 4231 6039 6215
;
RUN;
I can create a variable and do some stuff with it like,
%let N=12;
DATA faminc1b;
SET faminc ;
ARRAY Afaminc(12) faminc1-faminc12 ;
ARRAY Ataxinc(&N) taxinc1-taxinc&N ;
DO month = 1 TO &N;
Ataxinc(month) = Afaminc(month) * .10 ;
END;
RUN;
But I also want to divide every family income to the one before it.
The result should be like faminc1/faminc2 - faminc2/faminc3 - faminc3/faminc4...
So main problem is how to use arithmetic (+,-,*,/) operators to the "N" variable which i have created.
When I tried to simply do this, it doesnt work;
%let N=12;
DATA faminc1b;
SET faminc ;
ARRAY Afaminc(12) faminc1-faminc12 ;
ARRAY Afamdiv(&N) famdiv1-famdiv&N ;
DO month = 1 TO &N+1;
Afamdiv(month) = faminc&N/faminc&N+1 ;
END;
RUN;
Thanks for the help.