<?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 Blank Spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778511#M247816</link>
    <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create xml I write the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;

     set work.report end=eofl;
     file "&amp;amp;OUTFILE./&amp;amp;FILE_NAME." NOPRINT encoding="utf-8";
     by bankCode;

     if _n_ =1 then

           do;
                put '&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;';
                PUT '&amp;lt;currentDate&amp;gt;'currentDate'&amp;lt;/currentDate&amp;gt;';
                PUT '&amp;lt;factorCode&amp;gt;'factorCode'&amp;lt;/factorCode&amp;gt;';
                PUT '&amp;lt;monthReport&amp;gt;'monthReport'&amp;lt;/monthReport&amp;gt;';
                put '&amp;lt;banks&amp;gt;';
           end;

                   if first.bankCode then
           do;
                put '&amp;lt;bank bankCode="' bankCode'"&amp;gt;';
           end;&lt;BR /&gt;
     put '&amp;lt;branch branchId="' branchId'"&amp;gt;';
     put '&amp;lt;cityId&amp;gt;'cityId'&amp;lt;/cityId&amp;gt;';
     put '&amp;lt;cashierDesk&amp;gt;'cashierDesk'&amp;lt;/cashierDesk&amp;gt;';
     put '&amp;lt;coreBankBranchId&amp;gt;'coreBankBranchId'&amp;lt;/coreBankBranchId&amp;gt;';
     put '&amp;lt;cashDepositBag&amp;gt;'cashDepositBag'&amp;lt;/cashDepositBag&amp;gt;';
     put '&amp;lt;nonAtmDepositMachine&amp;gt;' nonAtmDepositMachine'&amp;lt;/nonAtmDepositMachine&amp;gt;';
     put '&amp;lt;/branch&amp;gt;';

     if last.bankCode then
           do;
                put '&amp;lt;/bank&amp;gt;';
           end;

     if eofl then
           do;
                put '&amp;lt;/banks&amp;gt;';
                put '&amp;lt;/cashServicesReport&amp;gt;';
           end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to remove blank spaces as shown by the arrows in the image, all fields come out with spaces.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shlomiohana_0-1636040579834.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65411i5AADAFA95C0385ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shlomiohana_0-1636040579834.png" alt="shlomiohana_0-1636040579834.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 15:46:46 GMT</pubDate>
    <dc:creator>shlomiohana</dc:creator>
    <dc:date>2021-11-04T15:46:46Z</dc:date>
    <item>
      <title>Remove Blank Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778511#M247816</link>
      <description>&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To create xml I write the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;

     set work.report end=eofl;
     file "&amp;amp;OUTFILE./&amp;amp;FILE_NAME." NOPRINT encoding="utf-8";
     by bankCode;

     if _n_ =1 then

           do;
                put '&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;';
                PUT '&amp;lt;currentDate&amp;gt;'currentDate'&amp;lt;/currentDate&amp;gt;';
                PUT '&amp;lt;factorCode&amp;gt;'factorCode'&amp;lt;/factorCode&amp;gt;';
                PUT '&amp;lt;monthReport&amp;gt;'monthReport'&amp;lt;/monthReport&amp;gt;';
                put '&amp;lt;banks&amp;gt;';
           end;

                   if first.bankCode then
           do;
                put '&amp;lt;bank bankCode="' bankCode'"&amp;gt;';
           end;&lt;BR /&gt;
     put '&amp;lt;branch branchId="' branchId'"&amp;gt;';
     put '&amp;lt;cityId&amp;gt;'cityId'&amp;lt;/cityId&amp;gt;';
     put '&amp;lt;cashierDesk&amp;gt;'cashierDesk'&amp;lt;/cashierDesk&amp;gt;';
     put '&amp;lt;coreBankBranchId&amp;gt;'coreBankBranchId'&amp;lt;/coreBankBranchId&amp;gt;';
     put '&amp;lt;cashDepositBag&amp;gt;'cashDepositBag'&amp;lt;/cashDepositBag&amp;gt;';
     put '&amp;lt;nonAtmDepositMachine&amp;gt;' nonAtmDepositMachine'&amp;lt;/nonAtmDepositMachine&amp;gt;';
     put '&amp;lt;/branch&amp;gt;';

     if last.bankCode then
           do;
                put '&amp;lt;/bank&amp;gt;';
           end;

     if eofl then
           do;
                put '&amp;lt;/banks&amp;gt;';
                put '&amp;lt;/cashServicesReport&amp;gt;';
           end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to remove blank spaces as shown by the arrows in the image, all fields come out with spaces.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="shlomiohana_0-1636040579834.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65411i5AADAFA95C0385ED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="shlomiohana_0-1636040579834.png" alt="shlomiohana_0-1636040579834.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 15:46:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778511#M247816</guid>
      <dc:creator>shlomiohana</dc:creator>
      <dc:date>2021-11-04T15:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Blank Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778526#M247827</link>
      <description>&lt;P&gt;I've run into a similar problem, and I need to use a +(-1) notation in the PUT step. See if this helps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/How-to-remove-trailing-blanks-when-PUT-statement-resolves-for/td-p/190655" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/How-to-remove-trailing-blanks-when-PUT-statement-resolves-for/td-p/190655&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 16:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778526#M247827</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2021-11-04T16:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Blank Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778560#M247835</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to add that this is expected behavior of &lt;EM&gt;list&lt;/EM&gt; output and explained in section&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0jcwhe1ofmb49n1xf1q2kc44b0v.htm#p01r92wbreaimwn1rr3o9u1uh6qt" target="_blank" rel="noopener"&gt;How List Output Is Spaced&lt;/A&gt; of the&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p0jcwhe1ofmb49n1xf1q2kc44b0v.htm" target="_blank" rel="noopener"&gt;PUT Statement: List&lt;/A&gt; documentation. As has been suggested, a &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1spe7nmkmi7ywn175002rof97fv.htm#p0jvsumcpb8j04n1glwmichpjfmx" target="_blank" rel="noopener"&gt;column pointer control&lt;/A&gt;&amp;nbsp;can be used to avoid the unwanted blanks (which do not occur with&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n0jks6tlw4a1v1n1ssob6gtpxfth.htm" target="_self"&gt;&lt;EM&gt;formatted&lt;/EM&gt; output&lt;/A&gt;).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To abbreviate the repeating pattern in your code, you could write a little macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro item(var);
  put "&amp;lt;&amp;amp;var&amp;gt;" &amp;amp;var +(-1) "&amp;lt;/&amp;amp;var&amp;gt;";
%mend item;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Application:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
set sashelp.class(obs=3);
%item(name)
%item(age)
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;&amp;lt;name&amp;gt;Alfred&amp;lt;/name&amp;gt;
&amp;lt;age&amp;gt;14&amp;lt;/age&amp;gt;
&amp;lt;name&amp;gt;Alice&amp;lt;/name&amp;gt;
&amp;lt;age&amp;gt;13&amp;lt;/age&amp;gt;
&amp;lt;name&amp;gt;Barbara&amp;lt;/name&amp;gt;
&amp;lt;age&amp;gt;13&amp;lt;/age&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 17:40:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-Blank-Spaces/m-p/778560#M247835</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-11-04T17:40:35Z</dc:date>
    </item>
  </channel>
</rss>

