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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1213 views
  • 0 likes
  • 2 in conversation