<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: proc sql create a table where and year(datepart(datetime)) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417810#M26905</link>
    <description>&lt;P&gt;Here's your code reworked in a way that (I hope) should work for Oracle.&amp;nbsp; I changed just the date functions -- not anything about your join logic.&amp;nbsp; I'm not conversant in Oracle SQL nuances.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname PRO Meta Library="PRO" METAOUT=DATA;
options nosymbolgen;
proc sql;
CONNECT TO ORACLE(AUTHDOMAIN="PRO" PATH="BI");
create table Table1 as
select primaryentityid , primaryentityclass, started, performerid, 1 as Web,
 year(started) as Year from connection to ORACLE
(
	select primaryentityid, started, performerid, primaryentityclass
	from activity a
	where (category in ( 'WEB') and year(started) ge 2017)
	union all
	select primaryentityid, started, performerid, primaryentityclass
	from activity_history ah
	where (category in ('WEB')and year(started) ge 2017)
);
DISCONNECT FROM ORACLE;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 01 Dec 2017 18:49:39 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2017-12-01T18:49:39Z</dc:date>
    <item>
      <title>proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417761#M26894</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if it is possible to had : and year(datepart(datetime)) gt 2016 in a where statement of proc sql create table test as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my test code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code is working:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table TableToday as&lt;BR /&gt;select *, YEAR(DATEPART(DATETIME)) AS Year&lt;BR /&gt;from SASHELP.GNGSMP2&lt;BR /&gt;where ID in ('A' , 'B') AND Calculated Year ge 2000;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following&amp;nbsp;below is not working.&amp;nbsp; Does anyone could help me with that issue?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname PRO Meta Library="PRO" METAOUT=DATA;&lt;BR /&gt;options nosymbolgen;&lt;BR /&gt;proc sql;&lt;BR /&gt;CONNECT TO ORACLE(AUTHDOMAIN="PRO" PATH="BI");&lt;BR /&gt;create table&amp;nbsp;Table1 as&lt;BR /&gt;select primaryentityid , primaryentityclass, started, performerid, 1 as Web,&lt;BR /&gt;year(datepart(started)) as&amp;nbsp;Year from connection to ORACLE&lt;BR /&gt;(&lt;BR /&gt;select primaryentityid, started, performerid, primaryentityclass&lt;BR /&gt;from activity a&lt;BR /&gt;where (category in ( 'WEB') and Calculated&amp;nbsp;Year ge 2017)&lt;/P&gt;&lt;P&gt;union all&lt;BR /&gt;select primaryentityid, started, performerid, primaryentityclass&lt;BR /&gt;from activity_history ah&lt;BR /&gt;where (category in ('WEB')and Calculated year ge 2017)&lt;BR /&gt;&lt;BR /&gt;);&lt;BR /&gt;DISCONNECT FROM ORACLE;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 15:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417761#M26894</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-12-01T15:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417762#M26895</link>
      <description>&lt;P&gt;DATEPART is a SAS function and Oracle can't process that.&amp;nbsp; When using explicit passthrough (CONNECT statement), use an Oracle function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I think YEAR() works with datetime values -- so YEAR(started), or EXTRACT(YEAR from Started).&amp;nbsp; This from Googling for Oracle doc -- I haven't tested.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 15:20:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417762#M26895</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-01T15:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417769#M26898</link>
      <description>&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 15:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417769#M26898</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-12-01T15:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417792#M26902</link>
      <description>&lt;P&gt;You are creating year locally in SAS, but try to use it in the pass-through to Oracle. Create it (using Oracle functions) in the pass-through.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 16:19:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417792#M26902</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-01T16:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417804#M26903</link>
      <description>&lt;P&gt;Hello Kurt,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you provide me an example how to do that?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 18:09:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417804#M26903</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-12-01T18:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417807#M26904</link>
      <description>&lt;P&gt;I'm no Oracle expert, so you best ask your Oracle specialists.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 18:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417807#M26904</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-12-01T18:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417810#M26905</link>
      <description>&lt;P&gt;Here's your code reworked in a way that (I hope) should work for Oracle.&amp;nbsp; I changed just the date functions -- not anything about your join logic.&amp;nbsp; I'm not conversant in Oracle SQL nuances.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname PRO Meta Library="PRO" METAOUT=DATA;
options nosymbolgen;
proc sql;
CONNECT TO ORACLE(AUTHDOMAIN="PRO" PATH="BI");
create table Table1 as
select primaryentityid , primaryentityclass, started, performerid, 1 as Web,
 year(started) as Year from connection to ORACLE
(
	select primaryentityid, started, performerid, primaryentityclass
	from activity a
	where (category in ( 'WEB') and year(started) ge 2017)
	union all
	select primaryentityid, started, performerid, primaryentityclass
	from activity_history ah
	where (category in ('WEB')and year(started) ge 2017)
);
DISCONNECT FROM ORACLE;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Dec 2017 18:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/417810#M26905</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2017-12-01T18:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/418784#M26964</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of my colleagues found the proper code I was looking for.&lt;/P&gt;&lt;P&gt;Here’s the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;CONNECT TO ORACLE(AUTHDOMAIN="PRO_REPL" PATH="BI_PROD");&lt;BR /&gt;create table SoumEnLigne as&lt;BR /&gt;select primaryentityid , primaryentityclass, started, performerid, Year(datepart(started)) as Year, 1 as Web from connection to ORACLE&lt;BR /&gt;(&lt;BR /&gt;select primaryentityid, started, performerid, primaryentityclass&lt;BR /&gt;from activity a&lt;BR /&gt;where started &amp;gt;=to_date('2017-01-01', 'yyyy-mm-dd')&lt;BR /&gt;)&lt;BR /&gt;union all&lt;BR /&gt;select primaryentityid, started, performerid, primaryentityclass&lt;BR /&gt;from activity_history ah&lt;BR /&gt;where started &amp;gt;=to_date('2017-01-01', 'yyyy-mm-dd')&lt;BR /&gt;)&lt;BR /&gt;);&lt;BR /&gt;DISCONNECT FROM ORACLE;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 13:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/418784#M26964</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-12-06T13:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql create a table where and year(datepart(datetime))</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/418786#M26965</link>
      <description>OK</description>
      <pubDate>Wed, 06 Dec 2017 13:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-create-a-table-where-and-year-datepart-datetime/m-p/418786#M26965</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2017-12-06T13:33:49Z</dc:date>
    </item>
  </channel>
</rss>

