<?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 Removing leading and trailing blanks of all the variables in all the datasets in a library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394050#M94925</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a library with 10 datasets and each dataset has 10 variables. If I want to remove the leading and trailing spaces for all the variables in all the datasets, I can do it manually by using STRIP function but for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;I would need to write 100 lines of code. How can I do that using macros and do it easily?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
    <pubDate>Thu, 07 Sep 2017 20:45:16 GMT</pubDate>
    <dc:creator>chandan_mishra</dc:creator>
    <dc:date>2017-09-07T20:45:16Z</dc:date>
    <item>
      <title>Removing leading and trailing blanks of all the variables in all the datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394050#M94925</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a library with 10 datasets and each dataset has 10 variables. If I want to remove the leading and trailing spaces for all the variables in all the datasets, I can do it manually by using STRIP function but for&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;that&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;I would need to write 100 lines of code. How can I do that using macros and do it easily?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 20:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394050#M94925</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2017-09-07T20:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading and trailing blanks of all the variables in all the datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394051#M94926</link>
      <description>&lt;P&gt;A few things to point out ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, you can only strip blanks from character variables.&amp;nbsp; Numeric variables are stored in a totally different form, and do not have leading or trailing blanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the way to process many variables in similar fashion is to use arrays:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;array chars {*} _character_;&lt;/P&gt;
&lt;P&gt;do _n_ = 1 to dim(chars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; chars{_n_} = strip(chars{_n_});&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to know the names of the variables, and it doesn't matter how many there are ... as long as your data set contains at least one character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Finally, once you do this you are likely to be unhappy with the result.&amp;nbsp; Stripping blanks does not change the length of the variable.&amp;nbsp; So if a variable has a length of $10 with 3 leading blanks and 3 trailing blanks, you can code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var = strip(var);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The STRIP function really works.&amp;nbsp; It removes the leading and trailing blanks.&amp;nbsp; But the result gets stored in VAR, which is still defined as 10 characters long.&amp;nbsp; So you will end up with 6 trailing blanks anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 20:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394051#M94926</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-07T20:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Removing leading and trailing blanks of all the variables in all the datasets in a library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394053#M94927</link>
      <description>&lt;P&gt;Thanks for the quick reply. It works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Chandan Mishra&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 21:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Removing-leading-and-trailing-blanks-of-all-the-variables-in-all/m-p/394053#M94927</guid>
      <dc:creator>chandan_mishra</dc:creator>
      <dc:date>2017-09-07T21:02:01Z</dc:date>
    </item>
  </channel>
</rss>

