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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2872 views
  • 0 likes
  • 4 in conversation