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
storeid | hlthfood | size | org | custid | gender | shopfor | veg | style | usecoup | week | seq | carry | coupval | amtspent | couponexpiry |
1 | 0 | 2 | 2 | 1 | 0 | 1 | 0 | 1 | 3 | 1 | 4 | 0 | 4 | 215.28 | 20/02/2014 |
1 | 0 | 2 | 2 | 1 | 0 | 1 | 0 | 1 | 3 | 2 | 4 | 4 | 3 | 0 | 21/02/2014 |
1 | 0 | 2 | 2 | 1 | 0 | 1 | 0 | 1 | 3 | 3 | 4 | 3 | 2 | 192.81 | 22/02/2014 |
1 | 0 | 2 | 2 | 1 | 0 | 1 | 0 | 1 | 3 | 4 | 4 | 2 | 1 | 8.24 | 23/02/2014 |
1 | 0 | 2 | 2 | 2 | 0 | 1 | 0 | 1 | 3 | 1 | 3 | 0 | 3 | 16.71 | 24/02/2014 |
1 | 0 | 2 | 2 | 2 | 0 | 1 | 0 | 1 | 3 | 2 | 3 | 3 | 1 | 171.91 | 25/02/2014 |
1 | 0 | 2 | 2 | 2 | 0 | 1 | 0 | 1 | 3 | 3 | 3 | 1 | 4 | 12.82 | 26/02/2014 |
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.
Post test data in the form of a datastep for next time, follow:
You code should look something like:
data want; set have; years=intck('year','31MAR2014'd,couponexpiry); run;
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.
This solution is working.
Thanks a lot
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.
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.