<?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: strip function not removing trailing spaces. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747735#M234745</link>
    <description>&lt;P&gt;proc sql;&lt;BR /&gt;select (strip(put(count(distinct usubjid), best.))) into :trt1 &lt;STRONG&gt;separated by ' '&lt;/STRONG&gt; from adam.adce where (TRT01AN=1);&lt;/P&gt;</description>
    <pubDate>Mon, 14 Jun 2021 10:28:59 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-06-14T10:28:59Z</dc:date>
    <item>
      <title>strip function not removing trailing spaces.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747678#M234722</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm using proc sql to create a macro of the counts per treatment group. However, when &amp;amp;trt1 and &amp;amp;trt2 resolves, there's a trailing space I cannot get rid of&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" image-alt="HitmonTran_0-1623644909840.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60316iA3F81CC0B3F6B745/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_0-1623644909840.png" alt="HitmonTran_0-1623644909840.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
	    	select (strip(put(count(distinct usubjid), best.))) into :trt1 from adam.adce where (TRT01AN=1);
			select (strip(put(count(distinct usubjid), best.))) into :trt2 from adam.adce where (TRT01AN=2);
			select (strip(put(count(distinct usubjid), best.))) into :trt3 from adam.adce where (TRT01AN=3);
quit;
	
%put &amp;amp;trt1 &amp;amp;trt2 &amp;amp;trt3;	

proc report data=final split='@';
	columns    ("&amp;amp;ALBL1.@(N=&amp;amp;trt1.)" group1 )   ("&amp;amp;PLBL1.@(N=&amp;amp;trt2.)" group2)  
				define group1 / "Any Grade." style(column)=[just=center];
				define group2/ "Grade 3+"   style(column)=[just=center];
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Jun 2021 04:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747678#M234722</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2021-06-14T04:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: strip function not removing trailing spaces.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747683#M234725</link>
      <description>&lt;P&gt;I would perform the STRIP()&amp;nbsp;&lt;EM&gt;after&lt;/EM&gt; the SQL completes.&amp;nbsp; The use of the : in an SQL statement to place a column into a macro variable invariably adds spaces which are a pain in the, um, posterior.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could code after the SQL but before the Proc Report:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET trt1 = %SYSFUNC(STRIP(&amp;amp;trt1));
%LET trt2 = %SYSFUNC(STRIP(&amp;amp;trt2));
%LET trt3 = %SYSFUNC(STRIP(&amp;amp;trt3));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 04:37:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747683#M234725</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2021-06-14T04:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: strip function not removing trailing spaces.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747735#M234745</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;select (strip(put(count(distinct usubjid), best.))) into :trt1 &lt;STRONG&gt;separated by ' '&lt;/STRONG&gt; from adam.adce where (TRT01AN=1);&lt;/P&gt;</description>
      <pubDate>Mon, 14 Jun 2021 10:28:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747735#M234745</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-06-14T10:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: strip function not removing trailing spaces.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747790#M234772</link>
      <description>&lt;P&gt;Use the TRIMMED keyword in SAS to have it "strip" the values being written into the macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select count(distinct usubjid) into :trt1 trimmed from adam.adce where (TRT01AN=1);
  select count(distinct usubjid) into :trt2 trimmed from adam.adce where (TRT01AN=2);
  select count(distinct usubjid) into :trt3 trimmed from adam.adce where (TRT01AN=2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you are sure you always have at least one record per TRT01AN you could simplify&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select count(distinct usubjid) into :trt1-
  from adam.adce where (TRT01AN in (1 2 3))
  group by TRT01AN
  order by TRT01AN
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Jun 2021 13:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/strip-function-not-removing-trailing-spaces/m-p/747790#M234772</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-14T13:13:09Z</dc:date>
    </item>
  </channel>
</rss>

