BookmarkSubscribeRSS Feed
sas_
Fluorite | Level 6

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

3 REPLIES 3
dhana
Fluorite | Level 6

Hi,

Please find attached one possible solution.

Thanks

Dhanasekaran R

sas_
Fluorite | Level 6

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

art297
Opal | Level 21

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1139 views
  • 3 likes
  • 3 in conversation