Write and run SAS programs in your web browser

How to apply INTCK and INTNX function in dataset ?

Occasional Contributor
Posts: 5

How to apply INTCK and INTNX function in dataset ?


I m new to SAS.   I am using SAS University Studio. I want to use INTCK and INTNX unction for given Dataset. 

I have imported following data-set  datetime in MYLIB library.


proc import datafile ="/folders/myfolders/testdata/datetime.xlsx"
out=mylib.datetime dbms=xlsx replace;

 There is dataset on which i want to perform INTCK function.






Thank you.


Super User
Super User
Posts: 9,599

Re: How to apply INTCK and INTNX function in dataset ?

You have not supplied any information for us to be able to help you.  Post your test data in the form of a datastep using the code window [ its the {i} above post are and following this post if needed:



Then show from this test data what you want to see out, and what the logic is.  Just saying I want to use XYZ function doesn't tell us anything, how do you want to use it, to get what?

Also note posting pictures of data does not help, we need to see the structure of the data to determine things, is that actually a SAS numeric datetime variable for instance?  Intck/nx need nuermic SAS datetime variables to work with.

Super User
Posts: 13,542

Re: How to apply INTCK and INTNX function in dataset ?

Basically you now need to use a data step program such as:


data want;

    set have;

    newvar = intck('interval',variable1,variable2); /* since you only have 1 datetime variable this is likely not what you want*/

    othernewvar = intnx('interval', variable, incrementnumber);



You can look up the syntax for INTX see what values are valid for interval. There are many options so do not expect a complete listing here. If you have a datetime variable and want to increment by day, week, month preface the interval with DT such as 'dtday' 'dtmonth'


More specific questions will yield better targeted responses.

Super User
Posts: 5,878

Re: How to apply INTCK and INTNX function in dataset ?

My recommendation is to start with the free SAS Programming 1 training, which will give you a foundation for SAS usage.
Right now learning SAS with fragments IMO pretty awkward and inefficient.
By the way, welcome to the wonderful and sometimes challenging world of SAS!
Data never sleeps
Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation