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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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