Data is created directly within the DATA step from date and time literals.
1 Code Block
DATA STEP Data
Explanation : This `_NULL_` DATA block initializes date and time variables. It applies formats for display and uses the `INTNX` function to calculate new values based on time intervals (month, day, hour). Finally, it displays the results in the SAS log.
Copied!
data _null_ ;
format date date7.
datetime datetime16.
time time8. ;
date=intnx('month','10oct97'd,0) ;
datetime=intnx('dtday','10oct97:12:34:56'dt,0) ;
time=intnx('hour','12:34't,0) ;
put date= / datetime= / time= ;
run ;
1
DATA _null_ ;
2
FORMAT date date7.
3
datetime datetime16.
4
time time8. ;
5
date=intnx('month','10oct97'd,0) ;
6
datetime=intnx('dtday','10oct97:12:34:56'dt,0) ;
7
time=intnx('hour','12:34't,0) ;
8
put date= / datetime= / time= ;
9
RUN ;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.