title: Character length in data step versus proc sql
body: <p>Is it possible that creating a table with SAS proc sql will truncate a character variable at 255 characters? Does it have to do with the library engine type?</p>
  
  <p>I'm using a PCFILES libname like this (note the dbmax_text option):</p>
  
  <pre><code>libname mylib PCFILES PATH = "C:\path\to\my\32bit\MS Acccess.ACCDB" dbmax_text=4000;
  </code></pre>
  
  <p>Then I do a proc sql like this:</p>
  
  <pre><code>proc sql noprint;
     create table work.cbdata as
      select 
          distinct var1,
          var2,
          ...
      from mylib.var2015
      where 
          upcase(var1) = "DIQ" 
      order by var1
    ;
  quit;
  </code></pre>
  
  <p><code>var2</code> is getting truncated at 255 even though it's format is listed as <code>$4000.</code> in the column property view. When I do this as a data step, all of the character data comes through:</p>
  
  <pre><code>data vardb;
    set mylib.var2015;
    if var1 = "DIQ";
  run;
  </code></pre>
  
  <p>I have 40-50 sql procedures like this embedded in my macro library, so I would prefer not to refactor all the macros to use data steps (if that's even possible). Does anyone know either</p>
  
  <p>a) if there is some option in proc sql to make it respect the dbmax_text.</p>
  
  <p>or</p>
  
  <p>b) any documentation about how SAS processes the character lengths in the create table statements of proc sql?</p>
  
  <p>EDIT - adding some screen shots.</p>
  
  <p>SAS thinks the variables are 4000 characters long:</p>
  
  <p><a href="https://i.stack.imgur.com/hof1D.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hof1D.jpg" alt="sas column properties showing 4000 length and format"></a></p>