<?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 message in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188223#M47673</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we don't assign length of a variable generated as a result of transtrn function the default length will be 200 bytes. As b is defined with length 7 bytes and value assigned to it through "set b=transtrn(a,substr(a,3,5),'aaaaa') " will be assumed as 200 bytes long. This will generate warning. Try this one to validate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;input a :$7. b $7. &lt;STRONG&gt;c $200.;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;1234123&lt;BR /&gt;2345234&lt;BR /&gt;4321432&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;update a&lt;BR /&gt;set &lt;STRONG&gt;c&lt;/STRONG&gt;=transtrn(a,substr(a,3,5),'aaaaa')&lt;/P&gt;&lt;P&gt;/*set b=substr(a,1,2)||'aaaaa' */&lt;BR /&gt;where a is not missing;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Jun 2014 21:04:56 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-06-06T21:04:56Z</dc:date>
    <item>
      <title>Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188222#M47672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please explain the reason for receiving the Warning message (SAS 9.2):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;character expression will be truncated when assigned to character column&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;when running the below code (which seems to execute correctly). The issue is that I have a macro that looks also for warnings and returns some messages which determines some future checks therefore the goal is not to have either warnings or errors in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the update is run in a data step the warning is not return, but I'd prefer the sql approach since the table might have&amp;nbsp; integrity constraints defined.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;infile datalines missover;&lt;/P&gt;&lt;P&gt;input a :$7. b $7.;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1234123&lt;/P&gt;&lt;P&gt;2345234&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4321432&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;update a&lt;/P&gt;&lt;P&gt;set b=transtrn(a,substr(a,3,5),'aaaaa')&lt;/P&gt;&lt;P&gt;/*set b=substr(a,1,2)||'aaaaa' */&lt;/P&gt;&lt;P&gt;where a is not missing;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10x,&lt;/P&gt;&lt;P&gt;Loko&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 20:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188222#M47672</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2014-06-06T20:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188223#M47673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If we don't assign length of a variable generated as a result of transtrn function the default length will be 200 bytes. As b is defined with length 7 bytes and value assigned to it through "set b=transtrn(a,substr(a,3,5),'aaaaa') " will be assumed as 200 bytes long. This will generate warning. Try this one to validate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;input a :$7. b $7. &lt;STRONG&gt;c $200.;&lt;/STRONG&gt;&lt;BR /&gt;datalines;&lt;BR /&gt;1234123&lt;BR /&gt;2345234&lt;BR /&gt;4321432&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;update a&lt;BR /&gt;set &lt;STRONG&gt;c&lt;/STRONG&gt;=transtrn(a,substr(a,3,5),'aaaaa')&lt;/P&gt;&lt;P&gt;/*set b=substr(a,1,2)||'aaaaa' */&lt;BR /&gt;where a is not missing;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 21:04:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188223#M47673</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-06T21:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188224#M47674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Naeem&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately I can not change the length of the variable since the table has already been created and the structure is long before defined; my only goal is to &lt;/P&gt;&lt;P&gt;update the value of this field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is not the matter only of the transtrn function . The commented code (the ones using the concatenation ) also generates the same warning.&lt;/P&gt;&lt;P&gt;It seems like proc sql does not perceive the variable as already defined and it returns a result with a length of 200 bytes which then squeezes within the variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 21:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188224#M47674</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2014-06-06T21:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188225#M47675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't get an error message when your exact code given is run, can you output your log by chance?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Jun 2014 21:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188225#M47675</guid>
      <dc:creator>Anotherdream</dc:creator>
      <dc:date>2014-06-06T21:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188226#M47676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Loko,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to change the length of variable to 200. This is just a warning that if the values are greater than 7 then it will be truncated. You will get&amp;nbsp; right values in your b variable becasue it is taking only 7 characters which is alright with the defined length of 7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Naeem&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2014 00:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188226#M47676</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-07T00:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188227#M47677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can change the length of variable without changing the table structure . &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;alter table work.have;&lt;/P&gt;&lt;P&gt; modify c char(200) ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2014 07:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188227#M47677</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-06-07T07:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188228#M47678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately, the changing of the table structure is not a solution, but since the expression returns a 200 bytes value then I use the &lt;EM&gt;input&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;function which eliminates the Warning message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, coming back to the initial issue, don't you think the warning doesn't have to appear in such caese?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10x,&lt;/P&gt;&lt;P&gt;L&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2014 07:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188228#M47678</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2014-06-07T07:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188229#M47679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So if the length of the target variable is known then use that to truncate the value that is being passed.&lt;/P&gt;&lt;P&gt;For example if the variable C is defined with length of 7 then you could&lt;/P&gt;&lt;P&gt;Change : &lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&lt;SPAN style="line-height: 1.5em; background-color: #ffffff;"&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em; background-color: #ffffff;"&gt;=transtrn(a,substr(a,3,5),'aaaaa')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;To&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 12pt;"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;&lt;STRONG&gt;c&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff;"&gt;=&lt;STRONG&gt;substrn(&lt;/STRONG&gt;transtrn(a,substr(a,3,5),'aaaaa')&lt;STRONG&gt;,1,7)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Jun 2014 17:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188229#M47679</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-06-07T17:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188230#M47680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom provided already a solution for the SQL syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I'd prefer the sql approach since the table might have&amp;nbsp; integrity constraints defined&lt;/SPAN&gt;"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;With a data step using MODIFY will allow you to change the table in place (instead of re-creating it) and though the table structure inclusive any indexes, constraints, audit trails &amp;amp; generation data sets will be maintained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines truncover dlm=' ' dsd;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input a :$7. b :$7. c :$200.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;1234123 1 1&lt;/P&gt;&lt;P&gt;2345234 2 2&lt;/P&gt;&lt;P&gt; 3 3&lt;/P&gt;&lt;P&gt;4321432 4 4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create index a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; on a (a);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; modify a;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where not missing(a);&lt;/P&gt;&lt;P&gt;&amp;nbsp; b=substr(a,1,2)||'aaaaa';&lt;/P&gt;&lt;P&gt;&amp;nbsp; replace;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc contents data=a;&lt;/P&gt;&lt;P&gt;run;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 08 Jun 2014 02:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188230#M47680</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-06-08T02:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Warning message</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188231#M47681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data a;&lt;BR /&gt;infile datalines missover;&lt;BR /&gt;input a :$7. b $7.;&lt;BR /&gt;datalines;&lt;BR /&gt;1234123&lt;BR /&gt;2345234&lt;BR /&gt;4321432&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;proc sql;&lt;BR /&gt;update a&lt;BR /&gt;set b=input(transtrn(a,substr(a,3,5),'aaaaa'),$7.)&lt;/P&gt;&lt;P&gt;/*set b=substr(a,1,2)||'aaaaa' */&lt;BR /&gt;where a is not missing;&lt;BR /&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jun 2014 01:01:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Warning-message/m-p/188231#M47681</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-06-09T01:01:51Z</dc:date>
    </item>
  </channel>
</rss>

