Help using Base SAS procedures

Format 20101222 15:59:57.94

Reply
Regular Contributor
Posts: 229

Format 20101222 15:59:57.94

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
Contributor
Posts: 53

Re: Format 20101222 15:59:57.94

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);
Super Contributor
Super Contributor
Posts: 3,174

Re: Format 20101222 15:59:57.94

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
Regular Contributor
Posts: 229

Re: Format 20101222 15:59:57.94

Ok thanks, i was on the good way as i had already splitted the datetime into a datepart and timepart. Thanks for the help.
Ask a Question
Discussion stats
  • 3 replies
  • 136 views
  • 0 likes
  • 3 in conversation