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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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