<?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: super simple proc sql vs. proc fedsql question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838997#M331730</link>
    <description>&lt;P&gt;Does not look like PROC FEDSQL supports dataset options.&lt;/P&gt;
&lt;PRE&gt;269  proc fedsql ;
270  create table x as
271  select *
272  from sashelp.class(where=(sex='M'))
273  ;
ERROR: Syntax error at or near "where"
274  quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.05 seconds
      cpu time            0.06 seconds


275  proc fedsql ;
276  create table x as
277  select *
278  from sashelp.class(drop=age)
279  ;
ERROR: Syntax error at or near "drop"
280  quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Oct 2022 15:02:00 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-10-17T15:02:00Z</dc:date>
    <item>
      <title>super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838992#M331727</link>
      <description>&lt;P&gt;Hi all I am a fairly experienced SAS programmer being given my first tastes of SAS VIYA and trying to get my head around it by having a play. can anyone explain to me why this works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table work.test_&amp;amp;monthname. as 
select asatdate,IFRS9Stage, sum(Current_Balance) as balance 
from public.ANON_ECL_&amp;amp;monthname.(where=(acct_scenario2=99)) 
group by 1, 2 
; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and this dosent:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fedsql; 
create table PUBLIC.test_&amp;amp;monthname. as 
select asatdate,IFRS9Stage, sum(Current_Balance) as balance 
from public.ANON_ECL_&amp;amp;monthname.(where=(acct_scenario2=99)) 
group by 1, 2 
; 
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the error I receive is "ERROR: Syntax error at or near "where"" and I have spent 30 mins googling to no avail... help me SAS community, you are my only hope!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 14:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838992#M331727</guid>
      <dc:creator>stewart_Jardine</dc:creator>
      <dc:date>2022-10-17T14:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838997#M331730</link>
      <description>&lt;P&gt;Does not look like PROC FEDSQL supports dataset options.&lt;/P&gt;
&lt;PRE&gt;269  proc fedsql ;
270  create table x as
271  select *
272  from sashelp.class(where=(sex='M'))
273  ;
ERROR: Syntax error at or near "where"
274  quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.05 seconds
      cpu time            0.06 seconds


275  proc fedsql ;
276  create table x as
277  select *
278  from sashelp.class(drop=age)
279  ;
ERROR: Syntax error at or near "drop"
280  quit;

NOTE: PROCEDURE FEDSQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 15:02:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838997#M331730</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-17T15:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838999#M331731</link>
      <description>&lt;P&gt;feels like a big oversight given the fact that CAS is all about speeding up processing, FEDSQL has to be used on CAS and dataset options are ususally used like this to limit input datasets and improve processing performance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for checking&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 15:05:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/838999#M331731</guid>
      <dc:creator>stewart_Jardine</dc:creator>
      <dc:date>2022-10-17T15:05:15Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839002#M331732</link>
      <description>&lt;P&gt;I think that FEDSQL is actually something that SAS bought from someone.&amp;nbsp; So it did not really know SAS syntax.&amp;nbsp; Apparently they have not enhanced it to support SAS syntax.&amp;nbsp; Perhaps that is a selling point as the code is then more likely to be portable (and can be pushed into a remote database).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 15:14:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839002#M331732</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-17T15:14:26Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839060#M331745</link>
      <description>&lt;P&gt;I would be surprised if a WHERE = dataset option performs any differently to a WHERE clause. To me dataset options are more applicable to DATA steps and I prefer to avoid these in SQL unless there is a good reason for it.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 19:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839060#M331745</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-10-17T19:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839068#M331749</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would be surprised if a WHERE = dataset option performs any differently to a WHERE clause. To me dataset options are more applicable to DATA steps and I prefer to avoid these in SQL unless there is a good reason for it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am totally ignorant on this topic.&amp;nbsp; But are you convinced that the WHERE clause will always be applied at data input time, just as a WHERE dataset option would be?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mean this.&amp;nbsp; Let's say &lt;EM&gt;&lt;STRONG&gt;filtervariable&lt;/STRONG&gt;&lt;/EM&gt; exists only on dataset B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table new
  as select * 
  from a 
  left join b (where=(filtervariable=filtervalue))
  on a.id=b.id
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the where clause is implemented at the input stage, so ineligible observations from b are not exposed to the join operation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But is the where filter also implemented at the input stage (vs after joining) in this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table new
  as select * 
  from a 
  left join b 
  on a.id=b.id
  where filtervariable=filtervalue
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to think so, but have never seen any documentation to that effect.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 20:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839068#M331749</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-10-17T20:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839072#M331752</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I would be surprised if a WHERE = dataset option performs any differently to a WHERE clause. To me dataset options are more applicable to DATA steps and I prefer to avoid these in SQL unless there is a good reason for it.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I am totally ignorant on this topic.&amp;nbsp; But are you convinced that the WHERE clause will always be applied at data input time, just as a WHERE dataset option would be?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I mean this.&amp;nbsp; Let's say &lt;EM&gt;&lt;STRONG&gt;filtervariable&lt;/STRONG&gt;&lt;/EM&gt; exists only on dataset B.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you run&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table new
  as select * 
  from a 
  left join b (where=(filtervariable=filtervalue))
  on a.id=b.id
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the where clause is implemented at the input stage, so ineligible observations from b are not exposed to the join operation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But is the where filter also implemented at the input stage (vs after joining) in this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table new
  as select * 
  from a 
  left join b 
  on a.id=b.id
  where filtervariable=filtervalue
  ;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I would like to think so, but have never seen any documentation to that effect.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your second example is going to give you a different result set as you are overriding the LEFT JOIN with a WHERE clause on B which will only allow rows obeying the filter to be kept.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the first example I would write it like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  create table new
  as select * 
  from a 
  left join 
  (select *
   from b 
   where filtervariable=filtervalue
 ) b
  on a.id=b.id
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 20:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839072#M331752</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-10-17T20:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839092#M331762</link>
      <description>&lt;P&gt;I use this syntax having moved the where clause from the right table parenthesis to the last 'on' statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
source MPG_toyota;
    create table MKT.FACT_OPE_FORM_OK_NODUP2{options replace=true} as 
      select a.*, b._frequency_
          from MKT.FACT_OPE_FORM_OK a inner join MKT.FACT_OPE_FORM_OK_NODUP b
      on a.codopera=b.codopera and a.codidoc=b.codidoc 
      and put(a._fecformo, ddmmyy10.)=put(b._fecformo, ddmmyy10.) 
      and b._frequency_ &amp;gt;= 2 ;
endsource;
fedSQL.execDirect / query=MPG_toyota;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 22:02:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839092#M331762</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-10-17T22:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839128#M331785</link>
      <description>&lt;P&gt;hey bud, it does process the data very differently actually, its much more efficient to drop all unecessary variables at compile stage than during the processing as the data will be read every time during processing&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 06:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839128#M331785</guid>
      <dc:creator>stewart_Jardine</dc:creator>
      <dc:date>2022-10-18T06:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: super simple proc sql vs. proc fedsql question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839133#M331788</link>
      <description>&lt;P&gt;just wanted to give a quick example using a relatively small dataset:&lt;/P&gt;&lt;P&gt;NOTE: The data set WORK.TEMP has 453310 observations and 157 variables.&lt;/P&gt;&lt;P&gt;28 proc sql;&lt;BR /&gt;28 ! create table temp2 as select&lt;BR /&gt;29 *&lt;BR /&gt;30 from temp(where=(current_balance&amp;gt;5000));&lt;/P&gt;&lt;P&gt;NOTE: Table WORK.TEMP2 created, with 419030 rows and 157 columns.&lt;/P&gt;&lt;P&gt;31 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 2.39 seconds&lt;BR /&gt;cpu time 2.39 seconds&lt;/P&gt;&lt;P&gt;32&lt;BR /&gt;33 proc sql;&lt;BR /&gt;33 ! create table temp2 as select&lt;BR /&gt;34 *&lt;BR /&gt;35 from temp&lt;BR /&gt;36 where current_balance&amp;gt;5000;&lt;BR /&gt;NOTE: Table WORK.TEMP2 created, with 419030 rows and 157 columns.&lt;/P&gt;&lt;P&gt;37 quit;&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 3.20 seconds&lt;BR /&gt;cpu time 2.54 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as you can see above the real time processing is almost a second quicker when processing at compile time and if you scale that up for big data, multiple users, multiple data sets it quickly becomes a big difference&lt;/P&gt;</description>
      <pubDate>Tue, 18 Oct 2022 07:28:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/super-simple-proc-sql-vs-proc-fedsql-question/m-p/839133#M331788</guid>
      <dc:creator>stewart_Jardine</dc:creator>
      <dc:date>2022-10-18T07:28:06Z</dc:date>
    </item>
  </channel>
</rss>

