Help using Base SAS procedures

Question regarding "intck"

Reply
N/A
Posts: 0

Question regarding "intck"

In my SAS dataset, there are 2 columns "Start_date" and "End_date", and in ($8.0) format, for example, "22/06/07", which is day, month and year respectively. I want to count the number of days between 2 dates for every record in these 2 columns. So I use "Interval = intck('day', End_date, start_date), and it keeps giving me errors in the log, showing for example " Invalid numeric data, start_date =' 22/06/07' ".

Must the End_date and Start_Date in the "intck" function be in certain format to get the number of days? If so, how can I convert them?
Super Contributor
Super Contributor
Posts: 3,174

Re: Question regarding "intck"

In a DATA step, use the INPUT function to convert your text-format date strings to SAS NUMERIC DATE variables.

Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Question regarding "intck"

I tried

Start_date_new = Input (Start_date, 8.);

And it doesn't work.
Super Contributor
Super Contributor
Posts: 3,174

Re: Question regarding "intck"

Of course, the string is not numeric, 8 digits. It is a date string, so your INFORMAT must match the input data format/type being processed.

Recommended SAS DOC reading - link below:

Working with Dates in the SAS System
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/a001304321.htm

The SAS support website http://support.sas.com/ provides both SAS product documentation and supplemental technical papers and code samples on this and other topics. Try the SEARCH option at the initial web page or consider using a Google advanced search argument, as shown below:

convert sas date variables site:sas.com


Scott Barry
SBBWorks, Inc.
N/A
Posts: 0

Re: Question regarding "intck"

I solved the problem. thanks! Message was edited by: grantxu2000
Ask a Question
Discussion stats
  • 4 replies
  • 114 views
  • 0 likes
  • 2 in conversation