<?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: creating macro variables via proc sql-remove spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498651#M132569</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;one solution would be to use the key word 'trimmed'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA tbl1;
   set sashelp.cars;
   numWords = countw(model, '');  
RUN;

PROC SQL noprint;
   SELECT  max(numWords) INTO :No_words TRIMMED
   FROM tbl1;  
QUIT;
%put &amp;amp;No_words.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Sep 2018 06:35:12 GMT</pubDate>
    <dc:creator>Oligolas</dc:creator>
    <dc:date>2018-09-25T06:35:12Z</dc:date>
    <item>
      <title>creating macro variables via proc sql-remove spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498647#M132567</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Please see a code to create a macro variable.&lt;/P&gt;&lt;P&gt;How can we remove spaces in the macro variable &amp;nbsp; &amp;amp;No_words.?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl1;
 set sashelp.cars;
numWords = countw(model, '');  
Run;



Proc SQL noprint;
select  max(numWords)  into   :No_words
 from tbl1;  
quit;
%put &amp;amp;No_words.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I know to do it in proc step but my question is how to do it in proc sql&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data tbl1;
 set sashelp.cars  end=eof;
       retain numWords 0;           
       numWords = max(numWords , countw(model, ''));    
       /* for each line of text, how many words */
       if eof then call symputX('No_words',numWords);
Run;
%put &amp;amp;No_words.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 06:03:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498647#M132567</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2018-09-25T06:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: creating macro variables via proc sql-remove spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498650#M132568</link>
      <description>&lt;P&gt;Simply add&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let No_words=&amp;amp;No_words;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;%let removes leading and trailing blanks.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 06:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498650#M132568</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-09-25T06:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: creating macro variables via proc sql-remove spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498651#M132569</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;one solution would be to use the key word 'trimmed'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA tbl1;
   set sashelp.cars;
   numWords = countw(model, '');  
RUN;

PROC SQL noprint;
   SELECT  max(numWords) INTO :No_words TRIMMED
   FROM tbl1;  
QUIT;
%put &amp;amp;No_words.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2018 06:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/498651#M132569</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2018-09-25T06:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: creating macro variables via proc sql-remove spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/593365#M170268</link>
      <description>&lt;P&gt;Thanks, that's useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Documentation here:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;INTO Clause&lt;BR /&gt;Assigns values produced by PROC SQL to macro variables.&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1y2jszlvs4hugn14nooftfrxhp3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1y2jszlvs4hugn14nooftfrxhp3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;&lt;EM&gt;Leading and trailing blanks are not trimmed from values before they are stored in macro variables&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;not as informative as documentation here:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;INTO Clause&lt;BR /&gt;Stores the value of one or more columns for use later in another PROC SQL query or SAS statement.&lt;BR /&gt;&lt;A href="https://support.sas.com/documentation/cdl//en/sqlproc/69822/HTML/default/viewer.htm#p0hwg3z33gllron184mzdoqwpe3j.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl//en/sqlproc/69822/HTML/default/viewer.htm#p0hwg3z33gllron184mzdoqwpe3j.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://support.sas.com/documentation/cdl//en/sqlproc/69822/HTML/default/viewer.htm#p0hwg3z33gllron184mzdoqwpe3j.htm#n1tupenuhmu1j0n19d3curl9igt4" target="_blank"&gt;https://support.sas.com/documentation/cdl//en/sqlproc/69822/HTML/default/viewer.htm#p0hwg3z33gllron184mzdoqwpe3j.htm#n1tupenuhmu1j0n19d3curl9igt4&lt;/A&gt;&lt;BR /&gt;&lt;EM&gt;TRIMMED&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;trims the leading and trailing blanks from values that are stored in a single macro variable.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 13:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/593365#M170268</guid>
      <dc:creator>ajs_rdg</dc:creator>
      <dc:date>2019-10-02T13:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: creating macro variables via proc sql-remove spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/593369#M170271</link>
      <description>&lt;P&gt;Note there is a FEEDBACK button on that first link.&amp;nbsp; So I used it to send them your link to the page that does include the TRIMMED option.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 13:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/creating-macro-variables-via-proc-sql-remove-spaces/m-p/593369#M170271</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-02T13:38:40Z</dc:date>
    </item>
  </channel>
</rss>

