BookmarkSubscribeRSS Feed
twildone
Pyrite | Level 9

Hi, I seem to be getting an error in the calculation of the number of days between two dates. For example, in my dataset, I have 20130220 and 20130415 and using the INTCK Function, I am getting -596 where it should be 55. Not too sure why or where the negative number is coming from. Thanks in advance.

DATA SUMMARY;

SET SUMMARY;

IF (ID = LAG(ID)) AND (CLAIM_DATE >= LAG(CLAIM_DATE)) THEN DO;

DIFF = INTCK('DAY',INPUT(PUT(LAG(CLAIM_DATE),8.),yymmdd8.),INPUT(PUT(CLAIM_DATE,8.),yymmdd8.))+1;

END;

RUN;

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Could you provide some test data there.  Not sure why you are putting lag(claim_date) to number then reading in as date. 

LinusH
Tourmaline | Level 20

Try to isolate your problem, i.e. separating your LAG(), input() and intck() into separate statements.

Use put _ALL_ to monitor the results of your operations.

But I have never really understood the value of using INTCK without arguments for straight dates. You just use simple subtraction on SAS dates....?

Data never sleeps
Loko
Barite | Level 11

hello,

probably it is because of LAG(CLAIM_DATE), executed conditionally. if sometimes the condition is not true the results are not the expected ones.

twildone
Pyrite | Level 9

Hi.....here is some output when I ran the code.

IDCLAIM_DATEDIFF
10000397620130709
1000039762013080837
1000039762013090933
1000039762013100729
1000039762013110429
1000039762013111411
10000402820130220
10000402820130415-596
1000040282013062269
1000040282013081959
1000040282013101659
1000040282013123177
1000040282014022456
10000998720120222
10000998720120319-951
1000099872012042033
1000099872012051930
1000099872012061831
1000099872012091792
1000099872012121994
10000998720130328100
twildone
Pyrite | Level 9

Thanks everyone. Apparently, it looks like the INTCK Function does not like the LAG Function as part of the Start or End Date. I created another variable for the Lag claim date and then used the new variable with the INTCK Function and it seems to work fine now.....Thanks Once Again.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 834 views
  • 8 likes
  • 4 in conversation