turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS Procedures
- /
- Using PROC SQL to run a query for Date column in a...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 02:52 PM

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,

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,

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 03:19 PM

look at the TIMEPART() function

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 03:19 PM

look at the TIMEPART() function

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 03:19 PM

look at the TIMEPART() function

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 04:26 PM

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.

Something like

timepart(sourcetime) > '16:00:00'T

will establish the criteria.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 04:26 PM

Something like

timepart(sourcetime) > '16:00:00'T

will establish the criteria.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 04:27 PM

Something like

timepart(sourcetime) > '16:00:00'T

will establish the criteria.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 04:27 PM

Something like

timepart(sourcetime) > '16:00:00'T

will establish the criteria.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 04:27 PM

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.

Something like

timepart(sourcetime) GT '16:00:00'T

will establish the criteria.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:45 PM

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

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:46 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:46 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:47 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:47 PM

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

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

11-19-2009 07:48 PM

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