Hi i am having data from jan08-----jul11
now i want the customers at which point he has started his payment and which is the last and if missed more that 3 months flag=0
i am giving for one year but i am having from jan08-jul11
ex
data cou;
input cus_id jan_08 feb_08 mar_08 apr_08 may_08 jun_08 jul_08 aug_08 sep_08 oct_08 nov_08 dec_08;
cards;
1324 56 . . . 45 67 78 . . . . .
1256 . . . . 45 . 78 . . . . 78
run;
output
cus_id jan_08 feb_08 mar_08 apr_08 may_08 jun_08 jul_08 aug_08 sep_08 oct_08 nov_08 dec_08 fir_mon las_mon flag
1324 56 . . . 45 67 78 . . . . . jan_08 jul_08 0
1256 . . . . 45 . 78 . . . . 78 may_08 dec_08 0
Hi,
Please find attached one possible solution.
Thanks
Dhanasekaran R
i wnat the month when the first payment and last payment is made i want them in to another varaibele in the output i have given the example as output
I probably would have coded it differently, but just modifying Dhana's code (if I correctly understand what you want), you might be able to use something like:
data count(keep=cus_id first last flag);
input cus_id jan_08 feb_08 mar_08 apr_08
may_08 jun_08 jul_08 aug_08 sep_08
oct_08 nov_08 dec_08
jan_09 feb_09 mar_09 apr_09
may_09 jun_09 jul_09 aug_09 sep_09
oct_09 nov_09 dec_09;
array my{*} jan_08--dec_09;
format first last date9.;
do pay_1=1 to dim(my);
if my(pay_1) ne . then do;
first=input(catt("01",
substr(vname(my(pay_1)),1,3),
"20",
substr(vname(my(pay_1)),5,2)),
date9.);
goto done;
end;
end;
done:
do pay_n=dim(my) to 1 by -1;
if my(pay_n) ^=. then do;
last=input(catt("01",
substr(vname(my(pay_n)),1,3),
"20",
substr(vname(my(pay_n)),5,2)),
date9.);
goto finish;
end;
end;
finish:
count=0;
do i=pay_1 to pay_n;
if my(i) =. then do;
count+1;
end;
end;
if count > 3 then flag=0;
cards;
1324 56 . . . 45 67 19 . . . . . 1 2 3 4 . . 7 8 9 0 1 2
1256 . . . . 45 . 78 . . . . 24 1 2 3 4 5 . . . . . . .
1257 1 2 3 4 45 . 78 . 5 5 5 24 1 2 3 4 . . . . . . . .
;
run;
HTH,
Art
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.