Help using Base SAS procedures

To fetch date difference without knowing end date.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 11
Accepted Solution

To fetch date difference without knowing end date.

I have following data set and want to calculate number of years from 31 march 2014 for each record from couponexpiry column.(USING INTCK FUNCTION)

Please revert with working solutions as soon as possible

thanks

 

storeidhlthfoodsizeorgcustidgendershopforvegstyleusecoupweekseqcarrycoupvalamtspentcouponexpiry
10221010131404215.2820/02/2014
10221010132443021/02/2014
10221010133432192.8122/02/2014
102210101344218.2423/02/2014
1022201013130316.7124/02/2014
10222010132331171.9125/02/2014
1022201013331412.8226/02/2014

Accepted Solutions
Solution
‎07-02-2017 05:44 AM
Super User
Posts: 10,500

Re: To fetch date difference without knowing end date.

Adding a bit to @RW9

Your couponexpiry date variable would have to be a SAS date valued numeric. If your current value is character you will need to create a date value using input(couponexpiry,ddmmyy10.) before any calculations.

 

And the literal date used, '31MAR2014'd has to be in that form. You cannot use '31/04/2014' or 04/31/2014' or someother data appearance. It must be as displayed by either the SAS Date9. or Date7. format when using a literal value.

View solution in original post


All Replies
Super User
Super User
Posts: 7,403

Re: To fetch date difference without knowing end date.

Post test data in the form of a datastep for next time, follow:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

You code should look something like:

data want;
  set have;
  years=intck('year','31MAR2014'd,couponexpiry);
run;

 

Solution
‎07-02-2017 05:44 AM
Super User
Posts: 10,500

Re: To fetch date difference without knowing end date.

Adding a bit to @RW9

Your couponexpiry date variable would have to be a SAS date valued numeric. If your current value is character you will need to create a date value using input(couponexpiry,ddmmyy10.) before any calculations.

 

And the literal date used, '31MAR2014'd has to be in that form. You cannot use '31/04/2014' or 04/31/2014' or someother data appearance. It must be as displayed by either the SAS Date9. or Date7. format when using a literal value.

Occasional Contributor
Posts: 11

Re: To fetch date difference without knowing end date.

This solution is working.

Thanks a lot

☑ This topic is SOLVED.

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

Discussion stats
  • 3 replies
  • 175 views
  • 0 likes
  • 3 in conversation