BookmarkSubscribeRSS Feed
Filipvdr
Pyrite | Level 9
Hello,

I got a data field which looks like 20101222 15:59:57.94

I need to find the dates which are in the last 24 and 48 hours. Can anybody tell me which format to use?

Kind Regards

Filip
3 REPLIES 3
mdavidson
Quartz | Level 8
This will subtract 24 hours from your date field. Change the -24 to whatever you want in order to add/subtract any number of hours from a date time.

intnx('hour', **insert your date field here**, -24);
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
INTNX is the correct function, however argument #1 needs to be "DTHOUR" for a SAS DATETIME variable. If your input data-string is a SAS CHARACTER variable, then you need to convert it to a SAS numeric type DATETIME variable, likely in a DATA step. One way is to split up the string into the DATE and TIME portions, then use the SAS INPUT function in assignment statements to convert each component, and then use a DHMS function to create your SAS DATETIME numeric variable.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

sas datetime variables site:sas.com
Filipvdr
Pyrite | Level 9
Ok thanks, i was on the good way as i had already splitted the datetime into a datepart and timepart. Thanks for the help.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1030 views
  • 0 likes
  • 3 in conversation