<?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: How to avoid truncation of newly created variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697882#M213370</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA FINAL2;
length message Message1 Message2 Message3 Message4 Message5 Message6 Message7 Message8 $2000.;
set pre;
if SEX~=I_DM_SEX_TXT then Message1=compbl("Error: "||SEX||" &amp;lt;&amp;gt; "||I_DM_SEX_TXT||".");
if vvalue(VISIT_DT)~=vvalue(DSSTDAT_C) then Message2=compbl("Error: "||VISIT_DT||" &amp;lt;&amp;gt; "||DSSTDAT_C||".");
if INDICATION~=I_STRATA_IND_TXT then Message3=compbl("Error: "||INDICATION||" &amp;lt;&amp;gt; "||I_STRATA_IND_TXT||".");
if strip(SUBTYPE)~=strip(I_STRATA_SUBT_TXT) then Message4=compbl("Error: "||SUBTYPE||" &amp;lt;&amp;gt; "||I_STRATA_SUBT_TXT||".");
if BASELINE_ANG_ATT_RATE~=I_STRATA_DRATE_TXT then Message5=compbl("Error: "||BASELINE_ANG_ATT_RATE||" &amp;lt;&amp;gt; "||I_STRATA_DRATE_TXT||".");
if SITE_NUMBER~=SITEMNEMONIC then Message6=compbl("Error: "||SITE_NUMBER||" &amp;lt;&amp;gt; "||SITEMNEMONIC||".");
if VISIT_TYPE~=EDC_VISIT_TYPE then Message7=compbl("Error: "||VISIT_TYPE||" &amp;lt;&amp;gt; "||EDC_VISIT_TYPE||".");
if SCREENING_NUM~=PATIENTNUMBER then Message8=compbl("Error: "||SCREENING_NUM||" &amp;lt;&amp;gt; "||PATIENTNUMBER||".");

MIS=STRIP(CATX(",",OF Message1-Message8));
IF MIS NE " " THEN message=STRIP(MIS); ELSE message=" ";
drop Message1-Message8;
if message ne "" ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above is the code, truncation is happening with the variable "message"&lt;/P&gt;</description>
    <pubDate>Tue, 10 Nov 2020 12:54:37 GMT</pubDate>
    <dc:creator>Ravindra_</dc:creator>
    <dc:date>2020-11-10T12:54:37Z</dc:date>
    <item>
      <title>How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697871#M213363</link>
      <description>&lt;P&gt;I have a variable which i had created by concatenating multiple other variables, but the text information within that variable in getting truncated and i had used the length of 2000 but of no use, i am still facing the same issue. Below is my code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA FINAL2;&lt;BR /&gt;length message Message1-Message8 $2000;&lt;BR /&gt;set pre;&lt;BR /&gt;if SEX~=I_DM_SEX_TXT then Message1=compbl("Error: "||SEX||" &amp;lt;&amp;gt; "||I_DM_SEX_TXT||".");&lt;BR /&gt;if strip(vvalue(VISIT_DT))~=strip(vvalue(DSSTDAT_C)) then Message2=compbl("Error: "||VISIT_DT||" &amp;lt;&amp;gt; "||DSSTDAT_C||".");&lt;BR /&gt;if INDICATION~=I_STRATA_IND_TXT then Message3=compbl("Error: "||INDICATION||" &amp;lt;&amp;gt; "||I_STRATA_IND_TXT||".");&lt;BR /&gt;if strip(SUBTYPE)~=strip(I_C1_SUBT_TXT) then Message4=compbl("Error: "||SUBTYPE||" &amp;lt;&amp;gt; "||I_C1_SUBT_TXT||".");&lt;BR /&gt;if BASELINE_ANG_ATT_RATE~=I_STRATA_DRATE_TXT then Message5=compbl("Error: "||BASELINE_ANG_ATT_RATE||" &amp;lt;&amp;gt; "||I_STRATA_DRATE_TXT||".");&lt;BR /&gt;if SITE_NUMBER~=SITEMNEMONIC then Message6=strip(compbl("Error: "||SITE_NUMBER||" &amp;lt;&amp;gt; "||SITEMNEMONIC||"."));&lt;BR /&gt;if VISIT_TYPE~=EDC_VISIT_TYPE then Message7=strip(compbl("Error: "||VISIT_TYPE||" &amp;lt;&amp;gt; "||EDC_VISIT_TYPE||"."));&lt;BR /&gt;if SCREENING_NUM~=PATIENTNUMBER then Message8=strip(compbl("Error: "||SCREENING_NUM||" &amp;lt;&amp;gt; "||PATIENTNUMBER||"."));&lt;/P&gt;&lt;P&gt;MIS=STRIP(CATX(",",OF Message1-Message8));&lt;BR /&gt;IF MIS NE " " THEN message=STRIP(MIS); ELSE message=" ";&lt;BR /&gt;drop Message1-Message8;&lt;BR /&gt;if message ne "" ;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me how to resolve this truncation issue.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 12:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697871#M213363</guid>
      <dc:creator>Ravindra_</dc:creator>
      <dc:date>2020-11-10T12:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697873#M213365</link>
      <description>&lt;P&gt;Sorry, but the code is an unreadable mess. Please post formatted code.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 12:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697873#M213365</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-11-10T12:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697874#M213366</link>
      <description>&lt;P&gt;We don't have your data, so we can't see the truncation you are seeing. Please provide a portion of your data following &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;, and not by any other method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DO NOT SKIP THIS STEP: please provide code in a SAS code by, by clicking on the "running man" icon and pasting your code into the window that appears. Your code is essentially unreadable as you have provided it.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 12:13:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697874#M213366</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-10T12:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697882#M213370</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA FINAL2;
length message Message1 Message2 Message3 Message4 Message5 Message6 Message7 Message8 $2000.;
set pre;
if SEX~=I_DM_SEX_TXT then Message1=compbl("Error: "||SEX||" &amp;lt;&amp;gt; "||I_DM_SEX_TXT||".");
if vvalue(VISIT_DT)~=vvalue(DSSTDAT_C) then Message2=compbl("Error: "||VISIT_DT||" &amp;lt;&amp;gt; "||DSSTDAT_C||".");
if INDICATION~=I_STRATA_IND_TXT then Message3=compbl("Error: "||INDICATION||" &amp;lt;&amp;gt; "||I_STRATA_IND_TXT||".");
if strip(SUBTYPE)~=strip(I_STRATA_SUBT_TXT) then Message4=compbl("Error: "||SUBTYPE||" &amp;lt;&amp;gt; "||I_STRATA_SUBT_TXT||".");
if BASELINE_ANG_ATT_RATE~=I_STRATA_DRATE_TXT then Message5=compbl("Error: "||BASELINE_ANG_ATT_RATE||" &amp;lt;&amp;gt; "||I_STRATA_DRATE_TXT||".");
if SITE_NUMBER~=SITEMNEMONIC then Message6=compbl("Error: "||SITE_NUMBER||" &amp;lt;&amp;gt; "||SITEMNEMONIC||".");
if VISIT_TYPE~=EDC_VISIT_TYPE then Message7=compbl("Error: "||VISIT_TYPE||" &amp;lt;&amp;gt; "||EDC_VISIT_TYPE||".");
if SCREENING_NUM~=PATIENTNUMBER then Message8=compbl("Error: "||SCREENING_NUM||" &amp;lt;&amp;gt; "||PATIENTNUMBER||".");

MIS=STRIP(CATX(",",OF Message1-Message8));
IF MIS NE " " THEN message=STRIP(MIS); ELSE message=" ";
drop Message1-Message8;
if message ne "" ;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The above is the code, truncation is happening with the variable "message"&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 12:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697882#M213370</guid>
      <dc:creator>Ravindra_</dc:creator>
      <dc:date>2020-11-10T12:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697883#M213371</link>
      <description>&lt;P&gt;And where did you set the length of MIS? Nowhere. So it is defined per default with a length of 200.&lt;/P&gt;
&lt;P&gt;See&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n0p7wxtk0hvn83n1pveisbcp2ae9.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;CATX Function&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;In a DATA step, if the CATX function returns a value to a variable that has not previously been assigned a length, that variable is given a length of 200 bytes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And that length is also returned by STRIP.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 13:08:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697883#M213371</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-10T13:08:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697884#M213372</link>
      <description>&lt;P&gt;You probably ought to declare a length on MIS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's not it, then as I requested, show us a portion of the data that illustrates the problem, using the method I linked to (and not using any other method)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 13:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697884#M213372</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-10T13:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697889#M213376</link>
      <description>Thanks a lot for identifying this, it resolved my issue.</description>
      <pubDate>Tue, 10 Nov 2020 13:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697889#M213376</guid>
      <dc:creator>Ravindra_</dc:creator>
      <dc:date>2020-11-10T13:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697890#M213377</link>
      <description>Thanks a lot for help, this had resolved the issue</description>
      <pubDate>Tue, 10 Nov 2020 13:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697890#M213377</guid>
      <dc:creator>Ravindra_</dc:creator>
      <dc:date>2020-11-10T13:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to avoid truncation of newly created variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697893#M213379</link>
      <description>&lt;P&gt;PS you do no need to strip the result of CATX, as CATX removes all leading and trailing blanks of all elements by itself; the receiving variable will be padded to its defined length as usual.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 14:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-avoid-truncation-of-newly-created-variable/m-p/697893#M213379</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-10T14:07:44Z</dc:date>
    </item>
  </channel>
</rss>

