BookmarkSubscribeRSS Feed
AminB
Fluorite | Level 6

Can something like the following be done in SAS?

if days(date1 - date2) = 200 then do....end

     (i.e. if # days difference is 200 then perform a task.

Similarly for months or years.

3 REPLIES 3
stat_sas
Ammonite | Level 13

Try intck to calculate number of days/months between two dates.

if intck('day',date1,date2) = 200 then do  /* for days */

if intck('month',date1,date2) = 200 then do  /* for months */

LionelT
Obsidian | Level 7

Assuming Date1 and Date2 are SAS dates would the following not work?

If (Date1 - date2) eq  200 then Do ;

end ;

For the months and years the Intck function woudl work as shown by stat@sas. Of course, we have not yet talked about 'alignment' on months and years!

CTorres
Quartz | Level 8

I would replace the if statement by if ABS(date1 - date2) eq 200 then Do; because we do not know what date is more recent.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 873 views
  • 6 likes
  • 4 in conversation