BookmarkSubscribeRSS Feed
Jsendzik
Fluorite | Level 6

Hey I need some help formatting some data I was recently given.

CustomerProductpurchase datedays_supply

a

R110/11/1330
aR210/11/1330
bR102/15/1330
bR203/15/1330
bR304/15/1360

I need to see all the days the customer had the product. Is there an easy way to do this or do I need to write some loops?

Thanks

4 REPLIES 4
LinusH
Tourmaline | Level 20

Could you please specify how you wish to see all these days? How do you intend to use it?

Data never sleeps
Jsendzik
Fluorite | Level 6

For now I'm only trying to find the total days overlap in multiple products by customer. The output would be 30 dates.

Ex. for row one:

customer  product  possession_date

a            r1          10/11/13

a            r1          10/12/13

a            r1          10/13/13

.              .

.

.

.

LinusH
Tourmaline | Level 20

Can't really see the end product. But if you want that desired output, I think a do-loop is the tool.

After outputting a row for each date, re-sort the table on customer, possession_date and product, and then use a data step with BY and first./last.-logic to create your desired output.

Data never sleeps
Jagadishkatam
Amethyst | Level 16

Please try,

data have;

    input customer$ product$ purchase_date : mmddyy10. days_supply;

    format     purchase_date mmddyy10.;

cards;

a    R1    10/11/13    30

a    R2    10/11/13    30

b    R1    02/15/13    30

b    R2    03/15/13    30

b    R3    04/15/13    60

;

run;

data want;

    set have;

    do possession_date= purchase_date to intnx('day',days_supply,purchase_date);

    output;

    end;

    format possession_date mmddyy10.;

run;

Thanks,

Jagadish

Thanks,
Jag

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!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1297 views
  • 0 likes
  • 3 in conversation