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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 4 replies
  • 754 views
  • 0 likes
  • 2 in conversation