<?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 PROC SQL to reformat variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141618#M37795</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your main issue is simply to reduce the size of your SAS datasets read from SQL Server I've found using COMPRESS = cures the problem easily without resizing columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table out.test (compress = yes or compress = binary) as select * from connection..... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jun 2014 03:15:22 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2014-06-13T03:15:22Z</dc:date>
    <item>
      <title>Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141614#M37791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a really large data set on a sql server that I'm trying to download.&amp;nbsp; The issue I'm having is the variable lengths are huge.&amp;nbsp; Most variables have a length of 255 when perhaps 8 would be appropriate.&amp;nbsp; How do I reformat the variables and simultaneously download the data?&amp;nbsp; I tried the code below but get the following error message: "ERROR: Describe error: IColumnsInfo::GetColumnInfo failed. : Deferred prepare could not be completed.: Statement(s) could not be prepared.: Incorrect syntax near 'format'."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;connect to oledb as codata (init_string="Provider=SQLOLEDB;Password=&amp;amp;pass.;Persist Security Info=True;User ID=&amp;amp;user.;&lt;/P&gt;&lt;P&gt;Initial Catalog=misc;Data Source=Sales" schema=dbo);&lt;/P&gt;&lt;P&gt;create table out.test as select * from connection to codata&lt;/P&gt;&lt;P&gt;&amp;nbsp; (select&lt;/P&gt;&lt;P&gt;&amp;nbsp; Idfield as&amp;nbsp; Idfield format=10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from &lt;/P&gt;&lt;P&gt;&amp;nbsp; superlargetable&lt;/P&gt;&lt;P&gt;);&lt;/P&gt;&lt;P&gt;disconnect from codata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note when I remove the format=10. the code works fine.&amp;nbsp; Thank you very much for any suggestions!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Bill&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 01:32:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141614#M37791</guid>
      <dc:creator>BillJones</dc:creator>
      <dc:date>2014-06-13T01:32:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141615#M37792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;I don't see in the code you provided this specific option, but maybe you have this turned on somewhere:&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;&lt;A class="active_link" href="http://support.sas.com/kb/38/542.html" title="http://support.sas.com/kb/38/542.html"&gt;38542 - A syntax error occurs when you specify the READ_LOCK_TYPE=NOLOCK option in a LIBNAME statement in SAS/ACCESS® Interface to OLE DB&lt;/A&gt;&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;Specifying READ_LOCK_TYPE=NOLOCK results in the building of a query that uses incorrect syntax.&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;To avoid this problem, do not specify READ_LOCK_TYPE=NOLOCK. If you do not specify the option, the software can open the DBMS tables in the SAS&lt;SPAN style="font-size: smaller; font-family: inherit;"&gt;®&lt;/SPAN&gt; Explorer window.&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;Maybe it helps.&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;The format syntax is correct.&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;&lt;/P&gt;&lt;P style="padding: 5px 0; font-size: small; font-family: Arial, Helvetica, Verdana, sans-serif; color: #333333;"&gt;Anca.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 02:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141615#M37792</guid>
      <dc:creator>AncaTilea</dc:creator>
      <dc:date>2014-06-13T02:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141616#M37793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're doing a direct pass through SQL query there, which will require you to user the native SQL language. I don't recognize your DB so can't comment beyond that &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 02:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141616#M37793</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-06-13T02:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141617#M37794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you need &lt;STRONG&gt;dbsastype&lt;/STRONG&gt; while loading variables which are huge in length from sql server. I've modified part of your syntax you can put it back to your main code to see if it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(select&lt;/P&gt;&lt;P&gt;&amp;nbsp; Idfield&lt;/P&gt;&lt;P&gt;from &lt;/P&gt;&lt;P&gt;&amp;nbsp; superlargetable &lt;STRONG&gt;(dbsastype=(Idfield='CHAR(10)'));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;disconnect from codata;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 02:40:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141617#M37794</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-13T02:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141618#M37795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If your main issue is simply to reduce the size of your SAS datasets read from SQL Server I've found using COMPRESS = cures the problem easily without resizing columns:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;create table out.test (compress = yes or compress = binary) as select * from connection..... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 03:15:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141618#M37795</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2014-06-13T03:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using PROC SQL to reformat variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141619#M37796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow, thank you everyone for all the suggestions.&amp;nbsp; I appreciate your thoughts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I didn't specify the &lt;SPAN style="color: #333333; font-family: Arial, Helvetica, Verdana, sans-serif; font-size: small; background-color: #ffffff;"&gt; READ_LOCK_TYPE=NOLOCK&lt;/SPAN&gt; option, so that wasn't the issue.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I tried the dbsastype syntax, but my query locked up.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifying (compress=yes) worked perfectly.&amp;nbsp; On a sample of obs=1000 the data set was compressed by over 96%.&amp;nbsp; I'm downloading the entire data set down right now.&amp;nbsp; I estimate that the file will be less than 50gb, which will be a huge improvement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; over what I would have ended up with.&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Thank you, SASKiwi!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best&lt;/P&gt;&lt;P&gt;Bill&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jun 2014 06:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-PROC-SQL-to-reformat-variables/m-p/141619#M37796</guid>
      <dc:creator>BillJones</dc:creator>
      <dc:date>2014-06-13T06:39:44Z</dc:date>
    </item>
  </channel>
</rss>

