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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 674 views
  • 0 likes
  • 3 in conversation