<?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 SQL Pass thru in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86836#M18538</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;connect to sybase (user=xxx pass=xxx server=xx connection=shared);&lt;/P&gt;&lt;P&gt;create table&amp;nbsp; crdmis._demog_curr&amp;nbsp; as&lt;BR /&gt;select * from connection to sybase&lt;BR /&gt;(&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; a.*&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; _demog_curr&amp;nbsp; a&lt;BR /&gt;);&lt;BR /&gt;disconnect from sybase;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table crdmis._demo_curr_v1 as&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.acct_no,b.cm11&lt;BR /&gt;from outdata_cntry_20 a left outer join crdmis.crdmis_demog_curr b&lt;BR /&gt; on substr(a.acct_no,1,11)=put(b.cm11,?32.)&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can this be done in step?The sybase table&amp;nbsp; _demog_curr is so huge, it is being written in the sas library.Is there a way where both these steps be combined into one and see final table crdmis._demo_curr_v1?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Nov 2012 19:24:16 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2012-11-30T19:24:16Z</dc:date>
    <item>
      <title>SQL Pass thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86836#M18538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;connect to sybase (user=xxx pass=xxx server=xx connection=shared);&lt;/P&gt;&lt;P&gt;create table&amp;nbsp; crdmis._demog_curr&amp;nbsp; as&lt;BR /&gt;select * from connection to sybase&lt;BR /&gt;(&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; a.*&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; _demog_curr&amp;nbsp; a&lt;BR /&gt;);&lt;BR /&gt;disconnect from sybase;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table crdmis._demo_curr_v1 as&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select a.acct_no,b.cm11&lt;BR /&gt;from outdata_cntry_20 a left outer join crdmis.crdmis_demog_curr b&lt;BR /&gt; on substr(a.acct_no,1,11)=put(b.cm11,?32.)&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can this be done in step?The sybase table&amp;nbsp; _demog_curr is so huge, it is being written in the sas library.Is there a way where both these steps be combined into one and see final table crdmis._demo_curr_v1?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 19:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86836#M18538</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2012-11-30T19:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86837#M18539</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have dealt with several types of database; unfortunately Sybase is not one of them. However, I know that Sybase largely complies with ANSI SQL just like other database.&amp;nbsp; So the absolute correctness in term of syntax will only be achieved by looking up Sybase SQL doc:&amp;nbsp; &lt;A href="http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookView/"&gt;http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookView&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Looks like you are troubled by the slow outer join done by SAS. The approach I would suggest requires you to have “write-permission” somewhere on your Sybase server, so that you can finish your join inside Sybase using its optimized engine.&amp;nbsp; Of course, code is not tested.&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/*to build a workplace on your Sybase server*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;libname&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; syb sybase user=xx password=xx server=xx;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/*to copy your SAS table back onto Sybase server*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; syb.a;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; outdata_cntry_20;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/*to let Sysbase do the join and transfer the results back to SAS*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;connect&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sybase (user=xxx pass=xxx server=xx connection=shared);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; crdmis._demo_curr_v1&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;as&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; * &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; connection to sybase&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;( &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; * &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; a &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;left&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;join&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _demog_curr b&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; substring(a.acct_no,&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;11&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;)=convert(&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;char&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;32&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;),b.cm11)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;disconnect&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; sybase;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;Haikuo&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 20:24:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86837#M18539</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-30T20:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86838#M18540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'll go the macro variable route, but there is a limit on the macro variable size. There is a way around that though if you get stuck.&lt;/P&gt;&lt;P&gt;You might need to fiddle with the macro variable a bit to get it in the exact method that SYBASE will need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*not sure of the formatting required, but you can fix that;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select put(acct_no, char32.) as acct_no&lt;/P&gt;&lt;P&gt;into :varlist&lt;/P&gt;&lt;P&gt;separated by ', '&lt;/P&gt;&lt;P&gt;from outdata_cntry_20;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;/P&gt;&lt;P&gt;connect to sybase (user=xxx pass=xxx server=xx connection=shared);&lt;/P&gt;&lt;P&gt;create table&amp;nbsp; crdmis._demog_curr&amp;nbsp; as&lt;BR /&gt;select * from connection to sybase&lt;BR /&gt;(&lt;BR /&gt;&amp;nbsp; select&amp;nbsp; a.*&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; _demog_curr&amp;nbsp; a&lt;/P&gt;&lt;P&gt;where b.cm11 in (&amp;amp;varlist);&lt;BR /&gt;);&lt;BR /&gt;disconnect from sybase;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: This is link to a workaround if your macro variable is too long. No idea if it works within pass through&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/46/109.html" title="http://support.sas.com/kb/46/109.html"&gt;http://support.sas.com/kb/46/109.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Nov 2012 20:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86838#M18540</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-11-30T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Pass thru</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86839#M18541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, SASPhile&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't done much with the Sybase engine, but I'm pretty sure both of the above suggestions will work with it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are a couple more:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. In your first query, you seem to be doing a select *, but in your second one you're only asking for cm11 from your table. If you can change your first select to "select a.cm11", you may reduce your data volume enough to make the process acceptable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. As a different way to tackle Reeza's suggestion, check out the following note. It shows how SAS can set up a long "where ... in(...)" clause, as a substitute for the join. I've never tried this myself, but it looks reasonable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#n0tcetvx1zpnayn1r8actrkjrd5o.htm"&gt;http://support.sas.com/documentation/cdl/en/acreldb/65247/HTML/default/viewer.htm#n0tcetvx1zpnayn1r8actrkjrd5o.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Dec 2012 15:32:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SQL-Pass-thru/m-p/86839#M18541</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2012-12-01T15:32:30Z</dc:date>
    </item>
  </channel>
</rss>

