SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
superbug
Quartz | Level 8

I want to convert time between to time points into month. if using (date2 - date1)/30, that doesn't take into account of months that have 31 days. what's the quick way of taking to account of month that have 30 and 31 days?

thank you!

 

 

 

3 REPLIES 3
novinosrin
Tourmaline | Level 20

I am guessing what you prolly need is to use INTCK function to get the count of monthly intervals between 2 dates

intck('month',date1,date2,'c');

/*or*/

intck('month',date1,date2);

  A small test to understand

 


%let date1='29dec2019'd;
%let date2='05jan2020'd;

data test;
 month_discrete=intck('month',&date1,&date2);
 month_continuous=intck('month',&date1,&date2,'c');
run;
superbug
Quartz | Level 8

@novinosrin  

you are always so helpful! Give you a BIG thumb up!

Yes, that worked! 

mkeintz
PROC Star
Then mark this topic as solved. It makes it easier for everybody to know in advance which topics are solved and which are not.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

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
  • 3 replies
  • 690 views
  • 1 like
  • 3 in conversation