<?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: Read varchar(max) from SQL Server into SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755649#M238502</link>
    <description>&lt;P&gt;What do you want to DO with the data? If it's just read it in, process, and write back to the database, then use PROC FedSQL for your SQL queries and PROC DS2 for your data programs. Those will work in SAS 9.4, the Viya Compute Server, and in CAS. &lt;BR /&gt;&lt;BR /&gt;If you want to write the data out to a SAS dataset in SAS 9.4 or on the Viya Compute Server, read it in DS2, write the data program code to split it up into several SAS character variables (CHAR), and save results to a SAS library. If you have access to CAS, you can load it right into an in-memory CAS table - &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/casref/p00irrg1pxzro6n1aadfcb1p3cag.htm#p16dym1b75c7u8n1qu8gxv8943en" target="_self"&gt;CAS VARCHAR&lt;/A&gt; supports up to&amp;nbsp;536,870,911 characters (in UTF-8 encoding).&lt;/P&gt;
&lt;P&gt;May the SAS be with you!&lt;BR /&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Jul 2021 14:50:03 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2021-07-21T14:50:03Z</dc:date>
    <item>
      <title>Read varchar(max) from SQL Server into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755583#M238481</link>
      <description>I have SQL Server table with columns of type varchar(max) and they hold values &amp;gt; 32767. How can i read the complete column in varchar(*) column using SAS V9 or SAS Viya ?</description>
      <pubDate>Wed, 21 Jul 2021 09:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755583#M238481</guid>
      <dc:creator>avinashjha1787</dc:creator>
      <dc:date>2021-07-21T09:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: Read varchar(max) from SQL Server into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755649#M238502</link>
      <description>&lt;P&gt;What do you want to DO with the data? If it's just read it in, process, and write back to the database, then use PROC FedSQL for your SQL queries and PROC DS2 for your data programs. Those will work in SAS 9.4, the Viya Compute Server, and in CAS. &lt;BR /&gt;&lt;BR /&gt;If you want to write the data out to a SAS dataset in SAS 9.4 or on the Viya Compute Server, read it in DS2, write the data program code to split it up into several SAS character variables (CHAR), and save results to a SAS library. If you have access to CAS, you can load it right into an in-memory CAS table - &lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/v_013/casref/p00irrg1pxzro6n1aadfcb1p3cag.htm#p16dym1b75c7u8n1qu8gxv8943en" target="_self"&gt;CAS VARCHAR&lt;/A&gt; supports up to&amp;nbsp;536,870,911 characters (in UTF-8 encoding).&lt;/P&gt;
&lt;P&gt;May the SAS be with you!&lt;BR /&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jul 2021 14:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755649#M238502</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2021-07-21T14:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Read varchar(max) from SQL Server into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755700#M238522</link>
      <description>I tried using Proc Casutil load statement to read data directly onto CAS&lt;BR /&gt;but it brings zero records for any table with varchar(max) variable.&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Jul 2021 16:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755700#M238522</guid>
      <dc:creator>avinashjha1787</dc:creator>
      <dc:date>2021-07-21T16:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: Read varchar(max) from SQL Server into SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755915#M238589</link>
      <description>&lt;P&gt;If you are using a LIBNAME to access your DBMS table and loading the data to CAS with code like this, you are performing a client-side load:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname db sqlsrv &amp;lt;connect info&amp;gt;;
proc casutil;
load data=db.mytable casout="myCASTable" outcaslib="casuser";
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="client-side-load.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61579i951974F14933D73B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="client-side-load.png" alt="client-side-load.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, in a client-side load the data is first processed by the SAS/ACCESS LIBNAME engine, and so your large VARCHAR column is truncated before you get a chance to load it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your CAS server has the associated data connector configured for your DBMS, you can do a server-side load instead. The code would look more like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;caslib sqlDB desc='Microsoft SQL Server Caslib' 
     dataSource=(srctype='sqlserver'
                 username='user1'
                 password='myPwd'
                 sqlserver_dsn="configured-DSN-name"
                 catalog='*');
proc casutil;
  load casdata="myTable" incaslib="sqlDB" 
       casout="myCASTable" outcaslib="casuser";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This loads the table directly from SQL Server to CAS using the CAS data connector:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="server-side-load.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/61580i1211F36111E1C634/image-size/medium?v=v2&amp;amp;px=400" role="button" title="server-side-load.png" alt="server-side-load.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see here, the LIBANME engine is not involved in this process, so the data is not converted to SAS numeric / fixed-width character before loading into CAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, are you doing a client-side load or a server-side load from SQL Server?&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 12:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-varchar-max-from-SQL-Server-into-SAS/m-p/755915#M238589</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2021-07-22T12:26:29Z</dc:date>
    </item>
  </channel>
</rss>

