<?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 PROC SQL truncates result of prxchange function in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497370#M131808</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a truncation problem with the prxchange function in proc sql, as illustrated in the attached code example.&amp;nbsp;The output string can be up to 609 chars long, and it has the defined length, but the content is truncated to 200 chars.&lt;/P&gt;
&lt;P&gt;This truncation does not occur when the function is used in a data step, but&amp;nbsp;I want to use the function in a&amp;nbsp;DI Studio, and company policy&amp;nbsp;requires us to use standard transformations (in this case Extract) and avoid user-written code as much as possible.&lt;/P&gt;
&lt;P&gt;So I hope somebody&amp;nbsp;has an idea to fix or circumvent this problem (other than a user-written data step).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Real data example - string can have max. length of 609 chars;
data a;
	length origstring $609;
	origstring = 'Odense Kommune\Ældre- og Handicapforvaltningen\Drift\Ældre og Handicap Nord\Forløb medfødt hjerneskade Nord\Botilbud medfødt hjerne' ||
	'skade Nord 2\Bo- og Støttetilbudet Nord-Vest\Bo- og Støttetilbud Hvedevangen';
run;

* Prxchange used in data step - works as expected;
data b; set a;
	length xlatestring $609;
	xlatestring = prxchange('s/\s?[&amp;amp;,\/\+]\s?/_/',-1,prxchange('s/([AI])\/(S)/$1$2/',-1,origstring ));
run;

data _null_; set b;
put origstring;
put xlatestring;
run;

* Prxchange used in proc sql - truncates to 200;
proc sql;
create table c as
	select 
		origstring,
		prxchange('s/\s?[&amp;amp;,\/\+]\s?/_/',-1,prxchange('s/([AI])\/(S)/$1$2/',-1,origstring )) as xlatestring length=609
	from a;
quit;

data _null_; set c;
put origstring;
put xlatestring;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tested in Windows 9.4m3 64 bit and Linux 9.4m5&amp;nbsp;&lt;SPAN&gt;64 bit.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 20 Sep 2018 14:13:56 GMT</pubDate>
    <dc:creator>ErikLund_Jensen</dc:creator>
    <dc:date>2018-09-20T14:13:56Z</dc:date>
    <item>
      <title>PROC SQL truncates result of prxchange function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497370#M131808</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a truncation problem with the prxchange function in proc sql, as illustrated in the attached code example.&amp;nbsp;The output string can be up to 609 chars long, and it has the defined length, but the content is truncated to 200 chars.&lt;/P&gt;
&lt;P&gt;This truncation does not occur when the function is used in a data step, but&amp;nbsp;I want to use the function in a&amp;nbsp;DI Studio, and company policy&amp;nbsp;requires us to use standard transformations (in this case Extract) and avoid user-written code as much as possible.&lt;/P&gt;
&lt;P&gt;So I hope somebody&amp;nbsp;has an idea to fix or circumvent this problem (other than a user-written data step).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Real data example - string can have max. length of 609 chars;
data a;
	length origstring $609;
	origstring = 'Odense Kommune\Ældre- og Handicapforvaltningen\Drift\Ældre og Handicap Nord\Forløb medfødt hjerneskade Nord\Botilbud medfødt hjerne' ||
	'skade Nord 2\Bo- og Støttetilbudet Nord-Vest\Bo- og Støttetilbud Hvedevangen';
run;

* Prxchange used in data step - works as expected;
data b; set a;
	length xlatestring $609;
	xlatestring = prxchange('s/\s?[&amp;amp;,\/\+]\s?/_/',-1,prxchange('s/([AI])\/(S)/$1$2/',-1,origstring ));
run;

data _null_; set b;
put origstring;
put xlatestring;
run;

* Prxchange used in proc sql - truncates to 200;
proc sql;
create table c as
	select 
		origstring,
		prxchange('s/\s?[&amp;amp;,\/\+]\s?/_/',-1,prxchange('s/([AI])\/(S)/$1$2/',-1,origstring )) as xlatestring length=609
	from a;
quit;

data _null_; set c;
put origstring;
put xlatestring;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tested in Windows 9.4m3 64 bit and Linux 9.4m5&amp;nbsp;&lt;SPAN&gt;64 bit.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:13:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497370#M131808</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2018-09-20T14:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL truncates result of prxchange function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497375#M131809</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a prxchanged string in your prxchange which is not given a length, hence the truncation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table c(drop=tempstr) as
	select 
		origstring,
		prxchange('s/([AI])\/(S)/$1$2/',-1,origstring ) as tempstr length=609,
		prxchange('s/\s?[&amp;amp;,\/\+]\s?/_/',-1,calculated tempstr) as xlatestring length=609
	from a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497375#M131809</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-09-20T14:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL truncates result of prxchange function</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497381#M131810</link>
      <description>&lt;P&gt;Of course. Thank you very much! - stupid of me not to figure that out myself.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Sep 2018 14:23:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-truncates-result-of-prxchange-function/m-p/497381#M131810</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2018-09-20T14:23:07Z</dc:date>
    </item>
  </channel>
</rss>

