<?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: TRANWRD function in SAS DI Studio expression in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/554238#M16992</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90188"&gt;@dsadsad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that you have got a solution, but I would like to explain your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use 2 functions in the same expression, which means that SAS creates a temporary variable to hold the result of the inner TRANWRD, which is then used as input to the outer TRANWRD. This variable is created with a default length of 200, and there is nothing you can do to change it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But a workaround is to split the expression in 2 using a temporary column like in this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length a $10 str $500;
	do x = 1 to 50;
		a = strip(put(x,2.))||'.................';
		str = catt(str,a);
	end;
run;

proc sql;
	create table bad as
		select tranwrd(tranwrd(str,'.','-'),'-','+') as str length=500
		from have;
quit;

proc sql;
	create table good (drop=tmp) as
		select
			tranwrd(str,'.','-') as tmp length=500,
			tranwrd(calculated tmp,'-','+') as str length=500
		from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Apr 2019 13:02:10 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2019-04-26T13:02:10Z</dc:date>
    <item>
      <title>TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553094#M16953</link>
      <description>&lt;P&gt;Hi DI Experts ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Field length is restricted to 200 char when&amp;nbsp; I am using tranwrd function to replace Tab and carriage return in the expression column in the field mappings in the table loader transformation. i have mentioned 1500 as length but still it is only limiting to 200&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Source is Teradata and Target is Oracle . Below is the expression used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;tranwrd(tranwrd(OFFER_REASON, '09'x,''),'0d0a'x,'')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any work around to get away with it ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 00:27:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553094#M16953</guid>
      <dc:creator>dsadsad</dc:creator>
      <dc:date>2019-04-23T00:27:47Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553356#M16959</link>
      <description>&lt;P&gt;How did you "mention 1500 as length"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should provide at least the code for the entire proc or data step using the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are attempting to replace with no character, i.e a zero length string, you may want the TRANSTRN function instead of TRANWRD. TRANWRD will replace with a single space&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 17:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553356#M16959</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-23T17:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553464#M16964</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90188"&gt;@dsadsad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looks like you just want to replace some control characters with blanks. You could use KTRANSLATE() for this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ktranslate(offer_reason,'a0a0a0'x,'090d0a'x)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl//en/nlsref/69741/HTML/default/viewer.htm#p10atr6djv8t88n16x5xgh2l30t5.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl//en/nlsref/69741/HTML/default/viewer.htm#p10atr6djv8t88n16x5xgh2l30t5.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 23:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553464#M16964</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-04-23T23:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553470#M16966</link>
      <description>&lt;P&gt;Hi Patrick , Thanks for responding . looks like ktranslate option is only runs on Z/OS as per the documentation. we use Linux Redhat.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2019 23:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553470#M16966</guid>
      <dc:creator>dsadsad</dc:creator>
      <dc:date>2019-04-23T23:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553476#M16967</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90188"&gt;@dsadsad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've actually tested the code I've posted with SAS under Linux and it works. I'm not sure what this z/OS specific comment in the documentation tries to express but it can't be that the function only works for z/OS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  offer_reason=cats('abcd','09'x,'xyz','0d0a'x,'abcd');
  offer_reason=ktranslate(offer_reason,'a0a0a0'x,'090d0a'x);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;....and with Linux you don't have to repeat the To value in the function if you just want it to become a blank. Below simplified version does the job as well.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  offer_reason=cats('abcd','09'x,'xyz','0d0a'x,'abcd');
  offer_reason=ktranslate(offer_reason,' ','090d0a'x);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Apr 2019 00:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/553476#M16967</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-04-25T00:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/554150#M16989</link>
      <description>&lt;P&gt;Thanks Patrick&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 04:25:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/554150#M16989</guid>
      <dc:creator>dsadsad</dc:creator>
      <dc:date>2019-04-26T04:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: TRANWRD function in SAS DI Studio expression</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/554238#M16992</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/90188"&gt;@dsadsad&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems that you have got a solution, but I would like to explain your problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use 2 functions in the same expression, which means that SAS creates a temporary variable to hold the result of the inner TRANWRD, which is then used as input to the outer TRANWRD. This variable is created with a default length of 200, and there is nothing you can do to change it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But a workaround is to split the expression in 2 using a temporary column like in this example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length a $10 str $500;
	do x = 1 to 50;
		a = strip(put(x,2.))||'.................';
		str = catt(str,a);
	end;
run;

proc sql;
	create table bad as
		select tranwrd(tranwrd(str,'.','-'),'-','+') as str length=500
		from have;
quit;

proc sql;
	create table good (drop=tmp) as
		select
			tranwrd(str,'.','-') as tmp length=500,
			tranwrd(calculated tmp,'-','+') as str length=500
		from have;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Apr 2019 13:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/TRANWRD-function-in-SAS-DI-Studio-expression/m-p/554238#M16992</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-04-26T13:02:10Z</dc:date>
    </item>
  </channel>
</rss>

