DATA Step, Macro, Functions and more

DATDIF FUNCTION

Reply
Occasional Contributor
Posts: 15

DATDIF FUNCTION

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.

Respected Advisor
Posts: 3,887

Re: DATDIF FUNCTION

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

Occasional Contributor
Posts: 15

Re: DATDIF FUNCTION

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

 

Ask a Question
Discussion stats
  • 2 replies
  • 150 views
  • 0 likes
  • 2 in conversation