<?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: PROC SQL: WARNING: Character expression will be truncated when assigned to character column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430070#M106286</link>
    <description>I need to use update with a subquery.</description>
    <pubDate>Tue, 23 Jan 2018 16:20:34 GMT</pubDate>
    <dc:creator>sspkmnd</dc:creator>
    <dc:date>2018-01-23T16:20:34Z</dc:date>
    <item>
      <title>PROC SQL: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430049#M106272</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data da;
    length a $20;
    a = 'asd';
run;

proc sql noprint;
    update da set a = (select cats(max(age), '.') from sashelp.class);
    update da set a = (select substrn(cats(max(age), '.'), 1, 20) from sashelp.class);
    update da set a = (select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class);
    update da set a = substrn((select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class), 1, 20);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All statements above produce a warning about truncation. Does anyone know how to get rid of them?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; KR&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 15:51:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430049#M106272</guid>
      <dc:creator>sspkmnd</dc:creator>
      <dc:date>2018-01-23T15:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430059#M106278</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do just&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	create table a as
	select cats(max(age), '.') as myvar from sashelp.class;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;by itself, and then look at the attributes of myvar you will see that it is $200, which is likely some sort of default length.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make the length of a in da longer or perhaps ALTER da with SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data da;
    length a $220;
    a = 'asd';
run;

proc sql noprint;
    update da set a = (select cats(max(age), '.') from sashelp.class);
    update da set a = (select substrn(cats(max(age), '.'), 1, 20) from sashelp.class);
    update da set a = (select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class);
    update da set a = substrn((select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class), 1, 20);
quit;

proc sql;
	alter table da 
	modify a varchar(20); 
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;doesn't throw any errors and may give you something to work with. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 16:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430059#M106278</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2018-01-23T16:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430069#M106285</link>
      <description>&lt;P&gt;You can avoid the $200 length by NOT using the cat family of functions. e.g.:&lt;/P&gt;
&lt;PRE&gt;data da;
    length a $20;
    a = 'asd';
run;

proc sql noprint;
    update da set a = (select strip(put(max(age),2.))||'.' from sashelp.class)
/*     update da set a = (select substrn(cats(max(age), '.'), 1, 20) from sashelp.class) */
/*     update da set a = (select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class) */
/*     update da set a = substrn((select substrn(cats(max(age), '.'), 1, 20) length=20 from sashelp.class), 1, 20) */
  ;
quit;&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 16:20:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430069#M106285</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-01-23T16:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430070#M106286</link>
      <description>I need to use update with a subquery.</description>
      <pubDate>Tue, 23 Jan 2018 16:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-WARNING-Character-expression-will-be-truncated-when/m-p/430070#M106286</guid>
      <dc:creator>sspkmnd</dc:creator>
      <dc:date>2018-01-23T16:20:34Z</dc:date>
    </item>
  </channel>
</rss>

