<?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: WARNING: Character expression will be truncated when assigned to character column in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811599#M320134</link>
    <description>&lt;P&gt;What's the length of&amp;nbsp;&lt;SPAN&gt;FIELDY as defined in&amp;nbsp;TABLEY. You can check with PROC CONTENTS:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data = TABLEY;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Note SAS datasets only have fixed length character variables. The length of the values stored is immaterial. Its the actual defined variable length that's important.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 05 May 2022 03:49:09 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2022-05-05T03:49:09Z</dc:date>
    <item>
      <title>WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811597#M320132</link>
      <description>&lt;P&gt;I have a data table where I have created a new field :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc sql;&lt;/P&gt;
&lt;P&gt;Alter table TABLEX&lt;/P&gt;
&lt;P&gt;add FIELDX varchar(30);&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Proc sql;&lt;BR /&gt;update TABLEX as A&lt;BR /&gt;set FIELDX = (select FIELDY from TABLEY as B&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; where a.MATCHKEY = b.MATCHKEY);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The max length of FIELDY is 10. Yet the update query results in a warning that halts the program.&lt;/P&gt;
&lt;P&gt;Am I doing something wrong or is there a workaround for this that I can apply in this situation?&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 02:05:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811597#M320132</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2022-05-05T02:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811599#M320134</link>
      <description>&lt;P&gt;What's the length of&amp;nbsp;&lt;SPAN&gt;FIELDY as defined in&amp;nbsp;TABLEY. You can check with PROC CONTENTS:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data = TABLEY;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Note SAS datasets only have fixed length character variables. The length of the values stored is immaterial. Its the actual defined variable length that's important.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 03:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811599#M320134</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-05-05T03:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811652#M320157</link>
      <description>&lt;P&gt;Yeah its set to 150 for some reason. So there's no way to select that field as a smaller variable when updating my field? I know i can just make my field 150 and it would work, but just trying to see other solutions.&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 12:38:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811652#M320157</guid>
      <dc:creator>Jyuen204</dc:creator>
      <dc:date>2022-05-05T12:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: WARNING: Character expression will be truncated when assigned to character column</title>
      <link>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811655#M320158</link>
      <description>&lt;P&gt;I can run code with your use case without ERROR - "just" a truncation WARNING&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tableY;
  length fieldY $150;
  fieldY='1234567890ABC';
  do matchkey=1 to 5;
    output;
  end;
  stop;
run;

data tableX;
  length fieldX $10;
  do matchkey=1,3,5;
    output;
  end;
  stop;
run;

Proc sql;
  update TABLEX as A
    set FIELDX = 
      (
        select FIELDY 
        from TABLEY as B
        where a.MATCHKEY = b.MATCHKEY
      )
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;IF you are 100% sure that the strings stored in FieldY are never longer than 10 characters then you could avoid the warning by converting the string to a length of 10. But be aware that this logic will actually truncate your source string without any warning if it's longer than 10 characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
  update TABLEX as A
    set FIELDX = 
      (
        select put(FIELDY,$10.) 
        from TABLEY as B
        where a.MATCHKEY = b.MATCHKEY
      )
  ;
quit;

proc print data=tableX;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2022 12:53:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/WARNING-Character-expression-will-be-truncated-when-assigned-to/m-p/811655#M320158</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-05-05T12:53:43Z</dc:date>
    </item>
  </channel>
</rss>

