DATA Step, Macro, Functions and more

make unique customer list in to duplicates by adding dates

Accepted Solution Solved
Reply
Contributor
Posts: 25
Accepted Solution

make unique customer list in to duplicates by adding dates

i have unique customers list, and would like to get each customer 31 times by adding one full month dates.

result supposed to be as attached.

Attachment

Accepted Solutions
Solution
‎07-18-2013 07:17 AM
Super Contributor
Posts: 282

Re: make unique customer list in to duplicates by adding dates

Hi,

Were you looking for something like the following:

data have;

  input custnbr $char6.;

  datalines;

123456

123457

123458

123459

123460

123461

123462

123463

123464

;

data want;

  set have;

  do date='01MAY13'd to '31MAY13'd;

    output;

  end;

run;

Regards,

Amir.

View solution in original post


All Replies
Solution
‎07-18-2013 07:17 AM
Super Contributor
Posts: 282

Re: make unique customer list in to duplicates by adding dates

Hi,

Were you looking for something like the following:

data have;

  input custnbr $char6.;

  datalines;

123456

123457

123458

123459

123460

123461

123462

123463

123464

;

data want;

  set have;

  do date='01MAY13'd to '31MAY13'd;

    output;

  end;

run;

Regards,

Amir.

Contributor
Posts: 25

Re: make unique customer list in to duplicates by adding dates

Thank you so much! can i ask one more question?

below XXXX is any interger.

if any decinmal value is greater than or equal XXXX.995 then it should become XXXX+1 else it should give lower integer XXXX

what could be the finction?

i am using some messy statement like below :

A = 564.995456

B = int(A) = 564

if A - B >= 0.995 then B = B + 1;

Super Contributor
Posts: 282

Re: make unique customer list in to duplicates by adding dates

Hi,

I'm glad my last post answered your question, feel free to mark it answered if you can and to raise a new discussion for a new question in future. On this occasion, I'm not aware of a function that would directly do what you are asking, but how about the following:

data _null_;

  a=564.995456; /* should become 565 */

  b=int(a+0.005);

  put a= b=;

 

  a=564.994456; /* should stay as 564 */

  b=int(a+0.005);

  put a= b=;

run;

Regards,

Amir.

Super Contributor
Posts: 282

Re: make unique customer list in to duplicates by adding dates

Hi,

If there is a chance that the original number could be missing then it might be worth using the sum function which would return 0 if the original was missing. E.g.:

b=int(sum(a,0.005));

Regards,

Amir.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 210 views
  • 5 likes
  • 2 in conversation