BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
I'm trying to run a query to check the SourceTime format (15JUL2009:16:12:07) is after 16:00 then create new column as AdjustedTime (16JUL2009:10:00:00), else AdjustedTime=SourceTime.

Appreciate for your assistance.

Thanks,
31 REPLIES 31
Flip
Fluorite | Level 6
look at the TIMEPART() function
Flip
Fluorite | Level 6
look at the TIMEPART() function
Flip
Fluorite | Level 6
look at the TIMEPART() function
Doc_Duke
Rhodochrosite | Level 12
Look at the documentation for the TIMEPART function. The CASE clause will allow you to do the decision breaks.

Something like
timepart(sourcetime) > '16:00:00'T
will establish the criteria.
Doc_Duke
Rhodochrosite | Level 12
Look at the documentation for the TIMEPART function. The CASE clause will allow you to do the decision breaks.

Something like
timepart(sourcetime) > '16:00:00'T
will establish the criteria.
Doc_Duke
Rhodochrosite | Level 12
Look at the documentation for the TIMEPART function. The CASE clause will allow you to do the decision breaks.

Something like
timepart(sourcetime) > '16:00:00'T
will establish the criteria.
Doc_Duke
Rhodochrosite | Level 12
Look at the documentation for the TIMEPART function. The CASE clause will allow you to do the decision breaks.

Something like
timepart(sourcetime) > '16:00:00'T
will establish the criteria.
Doc_Duke
Rhodochrosite | Level 12
Look at the documentation for the TIMEPART function. The CASE clause will allow you to do the decision breaks.

Something like
timepart(sourcetime) GT '16:00:00'T
will establish the criteria.
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton
milts
Pyrite | Level 9
Hi hope this is the solution you're looking for

proc sql;

select
case when
timepart(sourcetime) > '16:00:00't then
input(put(datepart(sourcetime)+1,date9.) || ' ' || '10:00:00',datetime.)
else
sourcetime
end
as adjustedtime format = datetime.
from table

quit;

There are probably other ways but this is the one that i came up with

Regards,
Milton

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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
  • 31 replies
  • 3104 views
  • 0 likes
  • 4 in conversation