<?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: Lagging Space Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579328#M164437</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a macro function and a mprint just to simplify the understanding of the code as macro variables are being used inside the code, please understand this is a code snippet not the whole code. The issue can not be seen if I use a proc print.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a SAS EG to see the output data from the resultant data set.&lt;/P&gt;&lt;P&gt;Issue:&lt;/P&gt;&lt;P&gt;In all the records given in odmds.test dataset, we are trying to remove the '#**' in the start and at the end.&lt;/P&gt;&lt;P&gt;In the process of doing that the substring and the tranwrd function is trimming the trailing spaces from the variable.&lt;/P&gt;&lt;P&gt;We need both leading and trailing spaces of the character string after removing&amp;nbsp;'#**' from the original string.&lt;BR /&gt;I was trying to get the desired result using prxchange but I could not get the correct regex for that, if I could get any help on that part it would be helpful too.&lt;/P&gt;&lt;P&gt;P.S. Please use the Base SAS editor or EG to see the output, so that u can see the spaces truncated in the process.&lt;/P&gt;&lt;P&gt;PSS, t is very hard to explain the issue with blank characters, I have tried in this forum earlier and it is very hard to do that. Kindly bear with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand SAS keeping a full char length, but when we upload these data to a database, no trailing spaces are loaded for these variables. Please use&amp;nbsp;Base SAS editor or EG to see the output text.&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2019 11:55:22 GMT</pubDate>
    <dc:creator>Satish_Parida</dc:creator>
    <dc:date>2019-08-06T11:55:22Z</dc:date>
    <item>
      <title>Trailing Space Truncation Issue (substr/tranwrd/praxchange)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579308#M164432</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are trying to remove the special pattern from start and end of the strings if present.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;

libname odmds 'D:\skp\odmds';

%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR);
%put &amp;amp;=splln.;

data odmds.test;
infile cards dlm=",";
input ItemData_Value:$100.;
cards;
#**    both leading and laging spaces    #**
#**    only leading spaces#**
#**only laging spaces    #**
;
run;

%macro spl_test;
	data odmds.test1;
	set odmds.test;
	if substr(strip(ItemData_Value),1,&amp;amp;splln) = "&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR." 
		= substr(strip(ItemData_Value),length(strip(ItemData_Value))-&amp;amp;splln.+1,&amp;amp;splln.) then do;
		ItemData_Value1 = substr(ItemData_Value,&amp;amp;splln+1,length(ItemData_Value)-2*&amp;amp;splln);
		ItemData_Value2 = tranwrd(ItemData_Value,"&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR",'');
		*ItemData_Value3 = prxchange('s/^#\*\*|#\*\*$,/', -1, ItemData_Value);	
	end;
	run;
%mend spl_test;
%spl_test;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Issue:&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;1. ItemData_Value1,&amp;nbsp;ItemData_Value2 are not retaining the trailing spaces how ever the leading spaces are retained.&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;2. Also if we can get any help on&amp;nbsp;ItemData_Value3 praxchange regex to replace the special character to null.&lt;/CODE&gt;&lt;/P&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;Thank you in advance.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;Note: Kindly use BASE SAS Editor or SAS EG to see the final dataset result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579308#M164432</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-08-06T12:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue [how to improve your question]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579318#M164433</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138619"&gt;@Satish_Parida&lt;/a&gt;,&lt;/P&gt;&lt;BR /&gt; &lt;P&gt;Your question requires more details before experts can help.&amp;nbsp;Can you revise your question to include more information?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Review this checklist:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Specify a meaningful subject line for your topic.&amp;nbsp; Avoid generic subjects like "need help," "SAS query," or "urgent."&lt;/LI&gt;
&lt;LI&gt;When appropriate, provide sample data in text or DATA step format.&amp;nbsp; See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;this article for one method&lt;/A&gt;&amp;nbsp;you can use.&lt;/LI&gt;
&lt;LI&gt;If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition.&amp;nbsp;Use the&amp;nbsp;&lt;STRONG&gt;Photos&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;button to include the image in your message.&lt;BR /&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 279px;"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/16608i91A52F817EAC9A69/image-dimensions/279x150?v=1.0" width="279" height="150" alt="use_buttons.png" title="use_buttons.png" /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;It also helps to include an example (table or picture) of the result that you're trying to achieve.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To edit your original message, select the "blue gear" icon at the top of the message and select&amp;nbsp;&lt;STRONG&gt;Edit Message&lt;/STRONG&gt;.&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;From there you can adjust the title and add more details to the body of the message.&amp;nbsp; Or, simply reply to this message with any additional information you can supply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" style="width: 229px;"&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/16605iAC020BC79315B045/image-size/large?v=1.0&amp;amp;px=600" alt="edit_post.png" title="edit_post.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;SAS experts are eager to help -- help&amp;nbsp;&lt;EM&gt;them&lt;/EM&gt; by providing as much detail as you can.&lt;/P&gt; &lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-style:italic;font-size:smaller;"&gt;This prewritten response was triggered for you by fellow SAS Support Communities member &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;.</description>
      <pubDate>Tue, 06 Aug 2019 11:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579318#M164433</guid>
      <dc:creator>Community_Guide</dc:creator>
      <dc:date>2019-08-06T11:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579319#M164434</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Issue:&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token number"&gt;1&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; ItemData_Value1&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; ItemData_Value2 are &lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; retaining the trailing spaces how ever the leading spaces are retained&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token number"&gt;2&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt; Also &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; we can get any help on ItemData_Value3 praxchange regex to &lt;SPAN class="token keyword"&gt;replace&lt;/SPAN&gt; the special character to null&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. SAS char variables always retain trailing spaces as they have a fixed length. So the question is unclear.&lt;/P&gt;
&lt;P&gt;If you were hoping to shorten the length of the variable, that is not possible.&amp;nbsp; The text can be shortened, not the variable.&lt;/P&gt;
&lt;P&gt;2. As explained, there is no null string in SAS. A string full of spaces is what is called a missing value in SAS, and what is evaluated as null in SQL.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 11:32:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579319#M164434</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-08-06T11:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579320#M164435</link>
      <description>&lt;P&gt;Forget the previous message (Community Guide), I hit the wrong button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First:&amp;nbsp;&lt;STRONG&gt;DO NOT USE MACRO CODE WHERE IT IS NOT NEEDED!!!!!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;It only makes reading the code harder and serves no purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, SAS character variables ALWAYS retain trailing spaces, as spaces are used to pad any content that is shorter than the defined variable length. A missing character variable therefore consists of blanks (spaces) only.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Third, you somehow missed to tell us what you really want.&lt;/P&gt;
&lt;P&gt;I ran your code with an additional proc print:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR);
%put &amp;amp;=splln.;

data test;
infile cards dlm=",";
input ItemData_Value:$100.;
cards;
#**    both leading and laging spaces    #**
#**    only leading spaces#**
#**only laging spaces    #**
;
run;


data test1;
set test;
if substr(strip(ItemData_Value),1,&amp;amp;splln) = "&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR." 
	= substr(strip(ItemData_Value),length(strip(ItemData_Value))-&amp;amp;splln.+1,&amp;amp;splln.) then do;
	ItemData_Value1 = substr(ItemData_Value,&amp;amp;splln+1,length(ItemData_Value)-2*&amp;amp;splln);
	ItemData_Value2 = tranwrd(ItemData_Value,"&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR",'');
	*ItemData_Value3 = prxchange('s/^#\*\*|#\*\*$,/', -1, ItemData_Value);	
end;
run;

proc print data=test1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Beob.    ItemData_Value                                  ItemData_Value1                       ItemData_Value2

  1      #**    both leading and laging spaces    #**        both leading and laging spaces        both leading and laging spaces
  2      #**    only leading spaces#**                       only leading spaces                   only leading spaces           
  3      #**only laging spaces    #**                    only laging spaces                    only laging spaces                
&lt;/PRE&gt;
&lt;P&gt;What should be different?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 11:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579320#M164435</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T11:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579328#M164437</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used a macro function and a mprint just to simplify the understanding of the code as macro variables are being used inside the code, please understand this is a code snippet not the whole code. The issue can not be seen if I use a proc print.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using a SAS EG to see the output data from the resultant data set.&lt;/P&gt;&lt;P&gt;Issue:&lt;/P&gt;&lt;P&gt;In all the records given in odmds.test dataset, we are trying to remove the '#**' in the start and at the end.&lt;/P&gt;&lt;P&gt;In the process of doing that the substring and the tranwrd function is trimming the trailing spaces from the variable.&lt;/P&gt;&lt;P&gt;We need both leading and trailing spaces of the character string after removing&amp;nbsp;'#**' from the original string.&lt;BR /&gt;I was trying to get the desired result using prxchange but I could not get the correct regex for that, if I could get any help on that part it would be helpful too.&lt;/P&gt;&lt;P&gt;P.S. Please use the Base SAS editor or EG to see the output, so that u can see the spaces truncated in the process.&lt;/P&gt;&lt;P&gt;PSS, t is very hard to explain the issue with blank characters, I have tried in this forum earlier and it is very hard to do that. Kindly bear with me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I understand SAS keeping a full char length, but when we upload these data to a database, no trailing spaces are loaded for these variables. Please use&amp;nbsp;Base SAS editor or EG to see the output text.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 11:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579328#M164437</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-08-06T11:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579331#M164438</link>
      <description>&lt;P&gt;You refuse to understand one of the most basic facts of SAS character variables: they are &lt;U&gt;&lt;STRONG&gt;ALWAYS&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;padded with blanks. ALWAYS. You can never lose "trailing spaces".&lt;/P&gt;
&lt;P&gt;You could only lose characters that are not hex 20's, but that is not what you have here.&lt;/P&gt;
&lt;P&gt;See this proof:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR);
%put &amp;amp;=splln.;

data test;
infile cards dlm=",";
input ItemData_Value:$50.;
cards;
#**    both leading and laging spaces    #**
#**    only leading spaces#**
#**only laging spaces    #**
;
run;


data test1;
set test;
if substr(strip(ItemData_Value),1,&amp;amp;splln) = "&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR." 
	= substr(strip(ItemData_Value),length(strip(ItemData_Value))-&amp;amp;splln.+1,&amp;amp;splln.) then do;
	ItemData_Value1 = substr(ItemData_Value,&amp;amp;splln+1,length(ItemData_Value)-2*&amp;amp;splln);
	ItemData_Value2 = tranwrd(ItemData_Value,"&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR",'');
	*ItemData_Value3 = prxchange('s/^#\*\*|#\*\*$,/', -1, ItemData_Value);	
  checkvalue1 = put(ItemData_Value1,$hex100.);
  checkvalue2 = put(ItemData_Value2,$hex100.);
end;
run;

proc print data=test1 noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;ItemData_Value                                  ItemData_Value1                       ItemData_Value2

#**    both leading and laging spaces    #**        both leading and laging spaces        both leading and laging spaces
#**    only leading spaces#**                       only leading spaces                   only leading spaces           
#**only laging spaces    #**                    only laging spaces                    only laging spaces                

                                            checkvalue1

20202020626F7468206C656164696E6720616E64206C6167696E672073706163657320202020202020202020202020202020
202020206F6E6C79206C656164696E6720737061636573202020202020202020202020202020202020202020202020202020
6F6E6C79206C6167696E67207370616365732020202020202020202020202020202020202020202020202020202020202020

                                            checkvalue2

2020202020626F7468206C656164696E6720616E64206C6167696E6720737061636573202020202020202020202020202020
20202020206F6E6C79206C656164696E67207370616365732020202020202020202020202020202020202020202020202020
206F6E6C79206C6167696E672073706163657320202020202020202020202020202020202020202020202020202020202020
&lt;/PRE&gt;
&lt;P&gt;You can see the blanks (all the 20's)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:07:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579331#M164438</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T12:07:05Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579332#M164439</link>
      <description>&lt;P&gt;PS if you want to make the contents of macro variables visible, use options symbolgen. No macro definition needed.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:08:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579332#M164439</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T12:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579333#M164440</link>
      <description>&lt;P&gt;PPS if you want a fixed defined length of character columns in a database, don't use varchar, use char instead.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579333#M164440</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T12:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579334#M164441</link>
      <description>&lt;P&gt;PPPS EG (and other dataset viewing tools) will always cut trailing blanks, just like a data step does when you are not using formatted output. If you want to mark a &lt;U&gt;certain amount&lt;/U&gt; of blanks, you always need a trailing non-blank character. By the definition, SAS can never know how many "visible trailing blanks" you wanted, as it only &lt;EM&gt;has&lt;/EM&gt; trailing blanks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:14:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579334#M164441</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T12:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579336#M164442</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for explaining me the SAS char variable properties.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue is when we insert these data into a Oracle table, I can not see any trailing space in the varchar2 field in the database.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the API which tries to match the original text and the final text in Oracle fails due to mismatching trailing spaces.&lt;BR /&gt;&lt;BR /&gt;One more thing I saw is, other blank characters such as Tab, LF and CR are not truncated if present at the end of the string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally I was trying to remove the '#**' using a praxchange, if you could help me with it.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579336#M164442</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-08-06T12:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579339#M164444</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So there is no way we can have certain number of trailing spaces for a SAS character variable?&lt;/P&gt;&lt;P&gt;PS, we checked we can have other blank characters(tab, CR, LF) at the end of the string.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579339#M164444</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-08-06T12:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579341#M164445</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options symbolgen;

%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR);
%put &amp;amp;=splln.;

data test;
infile cards dlm=",";
input ItemData_Value:$50.;
cards;
#**    both leading and laging spaces    #**
#**    only leading spaces#**
#**only laging spaces    #**
;
run;

data test1;
set test;
if
  substr(strip(ItemData_Value),1,&amp;amp;splln) = "&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR." =
  substr(strip(ItemData_Value),length(strip(ItemData_Value))-&amp;amp;splln.+1,&amp;amp;splln.)
then do;
  index = length(ItemData_Value) - 2*&amp;amp;splln + 1;
	ItemData_Value1 = substr(ItemData_Value,&amp;amp;splln+1,length(ItemData_Value)-2*&amp;amp;splln);
  substr(ItemData_Value1,index,1) = '00'x;
  checkvalue1 = put(ItemData_Value1,$hex100.);
end;
index1 = length(ItemData_Value1);
run;

proc print data=test1 noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I set an artificial end-of-string at the initial position of the trailing marker. It may be that this tricks a) SAS into transmitting the correct length and b) Oracle to accept the trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not versed in the prx functions, so somebody else needs to help you with that.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 12:37:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579341#M164445</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-08-06T12:37:32Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579479#M164487</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Why do you want to store trailing spaces into a VARCHAR() field?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Why not just store the length in a separate field and upload that along with the strings?&lt;/P&gt;
&lt;P&gt;You can then use logic in your external database to append trailing spaces.&lt;/P&gt;
&lt;P&gt;But again.&amp;nbsp;&lt;STRONG&gt;Why do you want to store trailing spaces into a VARCHAR() field?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let NON_PRINTABLE_ENCLOSING_CHAR=#**;
%let splln=%length(&amp;amp;NON_PRINTABLE_ENCLOSING_CHAR);
%put &amp;amp;=splln.;

data have;
  infile cards truncover ;
  input ItemData_Value $100.;
cards;
data have;
  infile cards truncover ;
  input ItemData_Value $100.;
cards;
#**...no leading or lagging spaces....#**
#**  both leading and lagging spaces  #**
#**                only leading spaces#**
#**only lagging spaces                #**
.
;

data want;
  set have;
  length=lengthn(itemdata_value);
  if length &amp;lt; 2*&amp;amp;splln. then do;
    length=0;
    itemdata_value=' ';
  end;
  else do;
    length=length-2*&amp;amp;splln.;
    itemdata_value=substr(itemdata_value,&amp;amp;splln+1,length);
  end;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;Obs    ItemData_Value                         length

 1     ...no leading or lagging spaces....      35
 2       both leading and lagging spaces        35
 3                     only leading spaces      35
 4     only lagging spaces                      35
 5                                               0&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Aug 2019 19:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579479#M164487</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-08-06T19:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: Lagging Space Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579528#M164501</link>
      <description>&lt;P&gt;Now that the behaviour of the trailing characters is clarified, here is the regex you might want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data TEST;
infile cards dlm=",";
input ItemData_Value : $100.;
ItemData_Value3 = prxchange('s/(^#\*\*|#\*\* *$|[[:^print:]])//', -1, ItemData_Value); &lt;BR /&gt;cards;
#**    both leading and laging spaces    #**
#**    only leading spaces#**
#**only laging #**spaces    #**
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It removes starting and ending &lt;FONT face="courier new,courier"&gt;#**&lt;/FONT&gt; as well as non-printable characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 23:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trailing-Space-Truncation-Issue-substr-tranwrd-praxchange/m-p/579528#M164501</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-08-06T23:05:01Z</dc:date>
    </item>
  </channel>
</rss>

