BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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?
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
In a DATA step, use the INPUT function to convert your text-format date strings to SAS NUMERIC DATE variables.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
I tried

Start_date_new = Input (Start_date, 8.);

And it doesn't work.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
deleted_user
Not applicable
I solved the problem. thanks! Message was edited by: grantxu2000

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2102 views
  • 0 likes
  • 2 in conversation