BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Jesusismygrace
Obsidian | Level 7

Hi,

 

I would like to calculate the following logic using the two date fields (DOS and IESD).

 

DOS on the IESD or in the 28 days following the IESD.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

The INTCK function will return number of intervals between date, time or datetime values, you specify the interval.

 

But example data and what you expect the result to look like will get you much further than use constantly guessing what you may have and what you want the result to look like.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

A data step is particularly helpful because we have people ask questions about "date" values and then after many "but that doesn't work" comments find out the actual values are not dates but character values or datetime values. SAS uses different values for storing dates and time or datetime values.

 

https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.

View solution in original post

5 REPLIES 5
AMSAS
SAS Super FREQ

You will need to provide more context as this really doesn't tell me anything 

Assuming they are both SAS Date values, then you can just subtract one from the other to get number of days

 

I suggest you provide some sample data and code, and the expected output

 

Data2DataStep Maco instructions

 

ballardw
Super User

The INTCK function will return number of intervals between date, time or datetime values, you specify the interval.

 

But example data and what you expect the result to look like will get you much further than use constantly guessing what you may have and what you want the result to look like.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the </> icon or attached as text to show exactly what you have and that we can test code against.

 

A data step is particularly helpful because we have people ask questions about "date" values and then after many "but that doesn't work" comments find out the actual values are not dates but character values or datetime values. SAS uses different values for storing dates and time or datetime values.

 

https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.

Jesusismygrace
Obsidian | Level 7
Thank you

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 16. 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
  • 5 replies
  • 648 views
  • 1 like
  • 5 in conversation