<?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: Using SUBSTR function in SAS 9.4 with SAS Studio in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/393729#M94840</link>
    <description>&lt;P&gt;In case anyone else runs into&amp;nbsp;a similar&amp;nbsp;issue, SAS Technical Support was able to give us a solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A modified&amp;nbsp;explanation from them:&amp;nbsp;"Starting in 9.4M2 when you are accessing Oracle 12c or later and your code includes (obs= ),&amp;nbsp;a "fetch first n rows" is appended to the query that is submitted to the database.&amp;nbsp; This results in Oracle only providing the&amp;nbsp;[first n observations]&amp;nbsp;to SAS which explains why the first [n] rows worked but [then] could no longer find the match. &amp;nbsp;Another piece to this issue is...using a function that is not passed to the database automatically.&amp;nbsp;&amp;nbsp;[Running] with [the SQL_FUNCTIONS= option&amp;nbsp;in your LIBNAME statement], the WHERE was passed to the database so the obs= didn't affect the pulling of results."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, we have added the "sql_functions = all" to our database libname statement, and that works.&amp;nbsp; Support also provided us these helpful links:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;A href="https://urldefense.proofpoint.com/v2/url?u=http-3A__support.sas.com_documentation_cdl_en_acreldb_69580_HTML_default_viewer.htm-23n0k1cax0gzsdxdn1a3466l1gwtk9.htm&amp;amp;d=DwMGAg&amp;amp;c=FC6t9d0KlExe-pgg9iXKnA&amp;amp;r=CHFRlzCuiZxdi-B_RMODUMpSYOQQikIjp4QGB4mKTng&amp;amp;m=xHvhST8E3r8k5J9zToufWcaQmUKZgJYFOjfpj-UJ_eI&amp;amp;s=XYywHiTbKrJwLkUlpBPmASWVKtscsCGExuNBy-fzrUY&amp;amp;e=" target="_blank"&gt;&lt;FONT color="#0000ff" face="Microsoft Sans Serif"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0k1cax0gzsdxdn1a3466l1gwtk9.htm&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;A href="https://urldefense.proofpoint.com/v2/url?u=http-3A__support.sas.com_documentation_cdl_en_acreldb_69580_HTML_default_viewer.htm-23p0f64yzzxbsg8un1uwgstc6fivjd.htm&amp;amp;d=DwMGAg&amp;amp;c=FC6t9d0KlExe-pgg9iXKnA&amp;amp;r=CHFRlzCuiZxdi-B_RMODUMpSYOQQikIjp4QGB4mKTng&amp;amp;m=xHvhST8E3r8k5J9zToufWcaQmUKZgJYFOjfpj-UJ_eI&amp;amp;s=RqRxcdrLqPHnh23cM_qFvnITSKylBT3UtLNVS-cTz-g&amp;amp;e=" target="_blank"&gt;&lt;FONT color="#0000ff" face="Microsoft Sans Serif"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#p0f64yzzxbsg8un1uwgstc6fivjd.htm&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 22:17:22 GMT</pubDate>
    <dc:creator>dolldata</dc:creator>
    <dc:date>2017-09-06T22:17:22Z</dc:date>
    <item>
      <title>Using SUBSTR function in SAS 9.4 with SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391261#M93946</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are running into an interesting problem...we are currently switching from SAS 9.2 (server) / 9.3 (desktop) to running SAS 9.4 on a virtual server and using SAS Studio. &amp;nbsp;[The upgrade has been a long time coming! &amp;nbsp;:-)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With the "old" SAS, the following query works perfectly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rsubmit;&lt;BR /&gt;proc print data = &lt;SPAN&gt;db&lt;/SPAN&gt;&lt;SPAN&gt;.customers&lt;/SPAN&gt; (obs = 10);&lt;BR /&gt;where substr(postal_code,1,5) = '04107';&lt;BR /&gt;var postal_code state;&lt;BR /&gt;run;&lt;BR /&gt;endrsubmit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;NOTE: There were 10 observations read from the data set DB.CUSTOMERS.&lt;BR /&gt;WHERE SUBSTR(postal_code, 1, 5)='04107';&lt;BR /&gt;NOTE: The PROCEDURE PRINT printed page 1.&lt;BR /&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;BR /&gt;real time 3.38 seconds&lt;BR /&gt;cpu time 0.06 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT:&lt;/P&gt;&lt;P&gt;Obs &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;POSTAL_CODE &amp;nbsp; STATE&lt;/P&gt;&lt;P&gt;75 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;041072704 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ME&lt;BR /&gt;8284 &amp;nbsp; &amp;nbsp; &amp;nbsp;041072615 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ME&lt;BR /&gt;15263 &amp;nbsp; &amp;nbsp;041079682&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;23753 &amp;nbsp; &amp;nbsp;041079603&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;25667 &amp;nbsp; &amp;nbsp;041071623&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;29707 &amp;nbsp; &amp;nbsp;041072615&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;34185 &amp;nbsp; &amp;nbsp;041071219&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;45532 &amp;nbsp; &amp;nbsp;041070257&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;58933 &amp;nbsp; &amp;nbsp;041071156&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;BR /&gt;68820 &amp;nbsp; &amp;nbsp;041071423&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;ME&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, in SAS Studio, on SAS 9.4, the following query yields zero observations, but we don't see any errors or problems in the notes:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data = &lt;SPAN&gt;db&lt;/SPAN&gt;&lt;SPAN&gt;.customers&lt;/SPAN&gt; (obs = 10);&lt;BR /&gt;where substr(postal_code,1,5) = '04107';&lt;BR /&gt;var postal_code state;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;DIV class="sasNote"&gt;NOTE: No observations were selected from data set DB.CUSTOMERS.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.06 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If we take the SUBSTR out and pull a specific postal code (all 9 characters), the query works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data = db.customers (obs = 10);&lt;BR /&gt;where postal_code = '041072704';&lt;BR /&gt;var postal_code state;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.20 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.09 seconds&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OUTPUT:&lt;/P&gt;&lt;P&gt;Obs POSTAL_CODE STATE 1 2 3&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;041072704&lt;/TD&gt;&lt;TD&gt;ME&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;041072704&lt;/TD&gt;&lt;TD&gt;ME&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;041072704&lt;/TD&gt;&lt;TD&gt;ME&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SUBSTR funciton works correctly within a PROC SQL statement.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's rare that we would use the SUBSTR function like this (in a&amp;nbsp;PROC PRINT), but the issue has us worried that&amp;nbsp;something has changed between the versions that could cause us to run into other issues, too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone have ideas on what we might be missing?&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 16:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391261#M93946</guid>
      <dc:creator>dolldata</dc:creator>
      <dc:date>2017-08-28T16:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR function in SAS 9.4 with SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391263#M93947</link>
      <description>&lt;P&gt;This is likely a SAS tech support question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One thing though - was the data imported in both or are you accessing a server or stored data somewhere?&lt;/P&gt;
&lt;P&gt;If it's imported moving from Windows to a Unix server that could be part of the issue.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 16:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391263#M93947</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-28T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR function in SAS 9.4 with SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391267#M93948</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;This is likely a SAS tech support question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One thing though - was the data imported in both or are you accessing a server or stored data somewhere?&lt;/P&gt;&lt;P&gt;If it's imported moving from Windows to a Unix server that could be part of the issue.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both attempts were accessing&amp;nbsp;the same database on a server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll submit a ticket to tech support as well. &amp;nbsp;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 16:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391267#M93948</guid>
      <dc:creator>dolldata</dc:creator>
      <dc:date>2017-08-28T16:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR function in SAS 9.4 with SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391270#M93950</link>
      <description>&lt;P&gt;The next check would the ODBC driver is my guess.&lt;/P&gt;
&lt;P&gt;Good Luck!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 16:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/391270#M93950</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-28T16:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using SUBSTR function in SAS 9.4 with SAS Studio</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/393729#M94840</link>
      <description>&lt;P&gt;In case anyone else runs into&amp;nbsp;a similar&amp;nbsp;issue, SAS Technical Support was able to give us a solution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A modified&amp;nbsp;explanation from them:&amp;nbsp;"Starting in 9.4M2 when you are accessing Oracle 12c or later and your code includes (obs= ),&amp;nbsp;a "fetch first n rows" is appended to the query that is submitted to the database.&amp;nbsp; This results in Oracle only providing the&amp;nbsp;[first n observations]&amp;nbsp;to SAS which explains why the first [n] rows worked but [then] could no longer find the match. &amp;nbsp;Another piece to this issue is...using a function that is not passed to the database automatically.&amp;nbsp;&amp;nbsp;[Running] with [the SQL_FUNCTIONS= option&amp;nbsp;in your LIBNAME statement], the WHERE was passed to the database so the obs= didn't affect the pulling of results."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, we have added the "sql_functions = all" to our database libname statement, and that works.&amp;nbsp; Support also provided us these helpful links:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;A href="https://urldefense.proofpoint.com/v2/url?u=http-3A__support.sas.com_documentation_cdl_en_acreldb_69580_HTML_default_viewer.htm-23n0k1cax0gzsdxdn1a3466l1gwtk9.htm&amp;amp;d=DwMGAg&amp;amp;c=FC6t9d0KlExe-pgg9iXKnA&amp;amp;r=CHFRlzCuiZxdi-B_RMODUMpSYOQQikIjp4QGB4mKTng&amp;amp;m=xHvhST8E3r8k5J9zToufWcaQmUKZgJYFOjfpj-UJ_eI&amp;amp;s=XYywHiTbKrJwLkUlpBPmASWVKtscsCGExuNBy-fzrUY&amp;amp;e=" target="_blank"&gt;&lt;FONT color="#0000ff" face="Microsoft Sans Serif"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#n0k1cax0gzsdxdn1a3466l1gwtk9.htm&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;A href="https://urldefense.proofpoint.com/v2/url?u=http-3A__support.sas.com_documentation_cdl_en_acreldb_69580_HTML_default_viewer.htm-23p0f64yzzxbsg8un1uwgstc6fivjd.htm&amp;amp;d=DwMGAg&amp;amp;c=FC6t9d0KlExe-pgg9iXKnA&amp;amp;r=CHFRlzCuiZxdi-B_RMODUMpSYOQQikIjp4QGB4mKTng&amp;amp;m=xHvhST8E3r8k5J9zToufWcaQmUKZgJYFOjfpj-UJ_eI&amp;amp;s=RqRxcdrLqPHnh23cM_qFvnITSKylBT3UtLNVS-cTz-g&amp;amp;e=" target="_blank"&gt;&lt;FONT color="#0000ff" face="Microsoft Sans Serif"&gt;http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#p0f64yzzxbsg8un1uwgstc6fivjd.htm&lt;/FONT&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 22:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-SUBSTR-function-in-SAS-9-4-with-SAS-Studio/m-p/393729#M94840</guid>
      <dc:creator>dolldata</dc:creator>
      <dc:date>2017-09-06T22:17:22Z</dc:date>
    </item>
  </channel>
</rss>

