<?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: Removing leading blanks when the next character is a zero. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136614#M261182</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wrote: "Use "put &amp;lt;your variable&amp;gt;= hex.;" in your code.".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;^^0791 Cathy .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;^^0437 David .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the log, and here my ^^ stands for blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should indicate that the white-space characters really are blanks. It is very strange then, that the strip function doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the dots come from I don't know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Sep 2014 11:59:50 GMT</pubDate>
    <dc:creator>attjooo</dc:creator>
    <dc:date>2014-09-09T11:59:50Z</dc:date>
    <item>
      <title>Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136610#M261178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The character variabel CHARVAR have values mostly like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0178 Adam&lt;/P&gt;&lt;P&gt;0245 Barbara&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But there are some values with some leading blanks like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;^^0791 Cathy&lt;/P&gt;&lt;P&gt;^^0437 David&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to get rid of the blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;STRIP(CHARVAR) and LEFT(CHARVAR) doesn´t work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any special problem with these functions, when the first character after the blanks is a zero?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The data are imported from Excel. I am using SAS Enterprise Guide.6.1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 09:42:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136610#M261178</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-09T09:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136611#M261179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, there is no such problem. Are you sure you're dealing with blanks or could it be that these are other non-printable white-space characters?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so then the most efficient way I can think of to get rid of any leading white-space characters would be using a regular expression as done in below code for "want2".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample;&lt;/P&gt;&lt;P&gt;&amp;nbsp; length have $20;&lt;/P&gt;&lt;P&gt;&amp;nbsp; have='09'x||'0791 Cathy';&lt;/P&gt;&lt;P&gt;&amp;nbsp; want1=strip(have);&lt;/P&gt;&lt;P&gt;&amp;nbsp; want2=prxchange('s/^\s*//o',1,have);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put have= $hex.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put want1= $hex.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; put want2= $hex.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Patrick Matter &#xD;
fixed the hex format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 10:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136611#M261179</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-09-09T10:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136612#M261180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your answer Patrick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some problems interpreting 's/^\s*//o'. Can you elaborate on that, please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And shouldn't the "1" in prxchange('s/^\s*//o',1,have) be "-1" if the number of non-printable characters are unknown?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have no idea of what the possible non-printable characters could be. I used "^" above to indicate blanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 11:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136612#M261180</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-09T11:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136613#M261181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use "put &amp;lt;your variable&amp;gt;= $hex.;" in your code. This will show you in the log the hex codes so you can find out what these white-space characters really are.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for the RegEx ^\s*&lt;/P&gt;&lt;P&gt;^&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at the beginning of the string&lt;/P&gt;&lt;P&gt;\s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; any white-space character&lt;/P&gt;&lt;P&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; zero, one or many&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And because this RegEx can match only once at the beginning of the string, a '1' should be sufficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Patrick Matter&#xD;
fixed the hex format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 11:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136613#M261181</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-09-09T11:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136614#M261182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You wrote: "Use "put &amp;lt;your variable&amp;gt;= hex.;" in your code.".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This gives:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;^^0791 Cathy .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;^^0437 David .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the log, and here my ^^ stands for blanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should indicate that the white-space characters really are blanks. It is very strange then, that the strip function doesn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the dots come from I don't know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 11:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136614#M261182</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-09T11:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136615#M261183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DOT come from you leaving off the period after the format HEX in your PUT statement.&amp;nbsp; It should be $HEX. and you may want to include W as in $HEX8.;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote" modifiedtitle="true"&gt;
&lt;P&gt;attjooo wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Where the dots come from I don't know.&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 12:04:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136615#M261183</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2014-09-09T12:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136616#M261184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You should have values like this is you really used the $HEX. format.&amp;nbsp; Only the '2020' are spaces. The others are other binary codes that might look like spaces when printed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;94&amp;nbsp;&amp;nbsp; data _null_;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;95&amp;nbsp;&amp;nbsp;&amp;nbsp; x='&amp;nbsp; 0791 Cathy';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;96&amp;nbsp;&amp;nbsp;&amp;nbsp; put x= $hex. ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;97&amp;nbsp;&amp;nbsp;&amp;nbsp; x='0000'x || '0791 Cathy';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;98&amp;nbsp;&amp;nbsp;&amp;nbsp; put x= $hex.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;99&amp;nbsp;&amp;nbsp;&amp;nbsp; x='A020'x || '0791 Cathy';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;100&amp;nbsp;&amp;nbsp; put x= $hex.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101&amp;nbsp;&amp;nbsp; x='0909'x || '0791 Cathy';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102&amp;nbsp;&amp;nbsp; put x= $hex.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;103&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;104&amp;nbsp; run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=202030373931204361746879&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=000030373931204361746879&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=A02030373931204361746879&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;x=090930373931204361746879&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 12:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136616#M261184</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-09T12:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136617#M261185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the legitimate characters always begin with a "0", then you shouldn't have to figure out what the extra character is.&amp;nbsp; You could try:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;length first $ 1;&lt;/P&gt;&lt;P&gt;first = charvar;&lt;/P&gt;&lt;P&gt;if first ne '0' then charvar = comrpess(charvar, first);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the first legitimate character might be a nonzero, the problem gets more complex but COMPRESS can probably handle it.&amp;nbsp; There is a third parameter for COMPRESS, for example, that would let you keep all letters and digits and discard everything else.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 12:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136617#M261185</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-09-09T12:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136618#M261186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My data above was fake data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using $hex. the problematic variable values all starts with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A0203036&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then 34 more digits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How should I interprete this?&lt;/P&gt;&lt;P&gt;¨'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 12:52:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136618#M261186</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-09T12:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136619#M261187</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;'A0'x is character that some (particularly Microsoft products) use as a "non-breaking" space.&amp;nbsp; Convert them to a real space and then STRIP() or LEFT() should work for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CHARVAR = left(translate(CHARVAR,' ','A0'x));&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Sep 2014 16:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136619#M261187</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-09-09T16:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136620#M261188</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Tom. My problem is now solved.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Sep 2014 06:06:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136620#M261188</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-10T06:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136621#M261189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then please mark the most suitable answer as "correct" and answers which were helpful as "helpful".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Sep 2014 09:41:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136621#M261189</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-09-10T09:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading blanks when the next character is a zero.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136622#M261190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was looking for a button marked "Correct" to press, but I couldn't find any.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Sep 2014 12:45:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-blanks-when-the-next-character-is-a-zero/m-p/136622#M261190</guid>
      <dc:creator>attjooo</dc:creator>
      <dc:date>2014-09-10T12:45:19Z</dc:date>
    </item>
  </channel>
</rss>

