BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nishant_saxena
Calcite | Level 5

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
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

 

ballardw
Super User

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.

Nishant_saxena
Calcite | Level 5

This solution is working.

Thanks a lot

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 678 views
  • 0 likes
  • 3 in conversation