Help using Base SAS procedures

Using PROC SQL to run a query for Date column in a table

Reply
N/A
Posts: 0

Using PROC SQL to run a query for Date column in a table

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,
Super Contributor
Posts: 359

Re: Using PROC SQL to run a query for Date column in a table

look at the TIMEPART() function
Super Contributor
Posts: 359

Re: Using PROC SQL to run a query for Date column in a table

look at the TIMEPART() function
Super Contributor
Posts: 359

Re: Using PROC SQL to run a query for Date column in a table

look at the TIMEPART() function
Valued Guide
Posts: 2,108

Re: Using PROC SQL to run a query for Date column in a table

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.
Valued Guide
Posts: 2,108

Re: Using PROC SQL to run a query for Date column in a table

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.
Valued Guide
Posts: 2,108

Re: Using PROC SQL to run a query for Date column in a table

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.
Valued Guide
Posts: 2,108

Re: Using PROC SQL to run a query for Date column in a table

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.
Valued Guide
Posts: 2,108

Re: Using PROC SQL to run a query for Date column in a table

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.
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Super Contributor
Posts: 304

Re: Using PROC SQL to run a query for Date column in a table

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
Ask a Question
Discussion stats
  • 31 replies
  • 132 views
  • 0 likes
  • 4 in conversation