<?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 Remove Leading blanks in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793351#M254269</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.cities;
	input city $char15.;
	datalines;
New York 
    Los Angeles
  Las Vegas  
  San   Diego
 
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How to remove leading blanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;left function cannot accomplish this task&lt;/P&gt;
&lt;P&gt;compress and strip both remove leading and trailling&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to remove only leading blanks from string&lt;/P&gt;</description>
    <pubDate>Sun, 30 Jan 2022 12:15:31 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2022-01-30T12:15:31Z</dc:date>
    <item>
      <title>Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793351#M254269</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.cities;
	input city $char15.;
	datalines;
New York 
    Los Angeles
  Las Vegas  
  San   Diego
 
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How to remove leading blanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;left function cannot accomplish this task&lt;/P&gt;
&lt;P&gt;compress and strip both remove leading and trailling&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to remove only leading blanks from string&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 12:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793351#M254269</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2022-01-30T12:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793354#M254272</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.cities;
	input city $char15.;
want=prxchange('s/^\s+//',1,city);
	datalines;
New York 
    Los Angeles
  Las Vegas  
  San   Diego
	xxxxxxxxx
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 30 Jan 2022 12:30:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793354#M254272</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-01-30T12:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793355#M254273</link>
      <description>&lt;P&gt;Please describe exactly how "left function cannot accomplish this task".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And perhaps do you mean more that just leading blanks? If you mean the extra spaces in the middle of "&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;San   Diego&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;those would not be "leading blanks".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also do not understand that "trailing blanks" are only of concern at certain uses. SAS character variables that are not defined the the full length of a variable will have "trailing blanks" only for some operations. Always.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.cities;
	input city $char15.;
	datalines;
New York 
    Los Angeles
  Las Vegas  
  San   Diego
 
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How to remove leading blanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;left function cannot accomplish this task&lt;/P&gt;
&lt;P&gt;compress and strip both remove leading and trailling&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i want to remove only leading blanks from string&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 12:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793355#M254273</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-30T12:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793357#M254274</link>
      <description>&lt;P&gt;Left function can does left allignment only it can not any string manuplations&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 12:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793357#M254274</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2022-01-30T12:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793358#M254275</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Left function can does left allignment only it can not any string manuplations&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Suggest that you try this code and see if that matches what you say above.&lt;/P&gt;
&lt;PRE&gt;data work.cities;
	input city $char15.;
   city=left(city);
	datalines;
New York 
    Los Angeles
  Las Vegas  
  San   Diego
;
run;
&lt;/PRE&gt;
&lt;P&gt;There are places in REPORT functions where Left is a justification and does not change the actual value. But the Function Left does just fine for removing spaces at the beginning of a string. If you have characters that don't visibly print and are not spaces, such as Tab or ASCII 255, it may appear as though the "space" was not removed because the actual character was not in fact a space.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 12:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793358#M254275</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-30T12:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793360#M254277</link>
      <description>&lt;P&gt;The $char informats are designed to preserve leading blanks.&amp;nbsp; If you don't want leading blanks, switch to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input city $15.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that any solution you use wlll leave CITY with a length of $15.&amp;nbsp; So any leading blanks that are removed will become trailing blanks instead, to reach that length of $15,.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not clear if you want to change multiple embedded blanks.&amp;nbsp; For example, do you want to end up with&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"San   Diego"&amp;nbsp;&amp;nbsp;vs.&amp;nbsp;"San&amp;nbsp;Diego"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If that is the issue, apply the COMPBL function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 13:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793360#M254277</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-01-30T13:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793401#M254299</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you have done with the input data, please supply another data step with datalines that show what output data you want based on the input data you have provided.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Based on the responses you've had so far, showing your desired output should help clarify your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To "&lt;SPAN&gt;remove leading blanks" (as per your subject title), you can look at the &lt;FONT face="courier new,courier"&gt;left()&lt;/FONT&gt; function definition and example in the&amp;nbsp;&lt;/SPAN&gt;&lt;A style="font-family: inherit; background-color: #ffffff;" href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1awii5zy0u6g0n1fy6yu1hwqiw4.htm" target="_blank" rel="noopener"&gt;documentation&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; to see if it should give you what you want.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 17:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793401#M254299</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2022-01-30T17:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Leading blanks</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793443#M254328</link>
      <description>&lt;P&gt;I assume that you both want to get rid of the leading blanks and reduce the multiple blanks inside the names to single blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the first thing, use LEFT. For the next thing, use COMPBL, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;city=left(compbl(city));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jan 2022 09:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Leading-blanks/m-p/793443#M254328</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-01-31T09:45:51Z</dc:date>
    </item>
  </channel>
</rss>

