BookmarkSubscribeRSS Feed
Bhargav_Movva
Fluorite | Level 6

Hi team,

 

        I have a dataset with startdate and enddate of certain task.All i wanted to know is the no of days between start and end of each task.But my input sas dataset contains date as character variable,so when i applied datdif function on the start and end date vars imk getting errors.Even tried to apply input function before executing Datdif function.

2 REPLIES 2
Patrick
Opal | Level 21

"Even tried to apply input function before executing Datdif function."

You're on the right track with this one. All SAS calendar functions like datdif() and intck() require the data to be a SAS date or SAS datetime value (=number of days or number of seconds since 1/1/1960).

 

The INPUT() function will help you to convert a character string into such a numeric SAS date/datetime value. You just need to apply the correct INFORMAT which instructs SAS how to convert this string into a date/datetime value.

 

Should you require more guidance: You need to post sample data (a data step creating such data) and then explain us what you need.

Bhargav_Movva
Fluorite | Level 6

Hey Patrick !!! thanks for the response.Issue resolved with your guidance..

 

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!

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