<?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 SAS Tip: Strip Blanks from PROC SQL-Created Macro Variable Values in SAS Tips from the Community</title>
    <link>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Strip-Blanks-from-PROC-SQL-Created-Macro-Variable-Values/m-p/442564#M169</link>
    <description>&lt;P&gt;A macro variable created with PROC SQL from a numeric variable or function contains leading blanks:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql; &lt;BR /&gt;  select count(*) into :howmany from SASHELP.CLASS; &lt;BR /&gt;quit; &lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|      19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An easy way to get rid of the leading blanks is as follows:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql;&lt;BR /&gt;  select count(*) into :howmany separated by ' ' from SASHELP.CLASS; &lt;BR /&gt;quit; &lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Posted with thanks to &lt;A href="http://robslink.com/SAS/Home.htm" target="_self"&gt;Robert Allison&lt;/A&gt;:&amp;nbsp;Since the original post, the TRIMMED option has been added to the INTO clause in PROC SQL to strip blanks:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql;&lt;BR /&gt;  select count(*) into :howmany trimmed from SASHELP.CLASS;&lt;BR /&gt;quit;&lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;!-- Insert any appropriate category tags. Note that it is important to put the categorys inside the &lt;noinclude&gt; block so the categories are only applied to the tip page.- You can have as many CATEGORY tag lines as you want.--&gt;&lt;!-- Provide links to other resources:- If the links are pages on sasCommunity update the "WikiReadMore" line and replace "PAGENAME" with the name of the sasCommunity.org page.- If the links are external (e.g., the sas support site, other external links, and so on, updated the "External ReadMore" line and replace "URL" with the full url including the http:- You can include as many of these lines as you want- if you don't have such links, just delete the line(s)--&gt;&lt;!-- Please do not edit below this line, EXCEPT when promoting a tip --&gt;
&lt;DIV style="float: right;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;See the documentation for the INTO clause &lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1y2jszlvs4hugn14nooftfrxhp3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;Thanks to Mike Zdeb&amp;nbsp;for sharing this tip on sasCommunity.org.&lt;/P&gt;</description>
    <pubDate>Sat, 12 May 2018 11:22:40 GMT</pubDate>
    <dc:creator>SAS_Tipster</dc:creator>
    <dc:date>2018-05-12T11:22:40Z</dc:date>
    <item>
      <title>SAS Tip: Strip Blanks from PROC SQL-Created Macro Variable Values</title>
      <link>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Strip-Blanks-from-PROC-SQL-Created-Macro-Variable-Values/m-p/442564#M169</link>
      <description>&lt;P&gt;A macro variable created with PROC SQL from a numeric variable or function contains leading blanks:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql; &lt;BR /&gt;  select count(*) into :howmany from SASHELP.CLASS; &lt;BR /&gt;quit; &lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|      19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An easy way to get rid of the leading blanks is as follows:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql;&lt;BR /&gt;  select count(*) into :howmany separated by ' ' from SASHELP.CLASS; &lt;BR /&gt;quit; &lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Posted with thanks to &lt;A href="http://robslink.com/SAS/Home.htm" target="_self"&gt;Robert Allison&lt;/A&gt;:&amp;nbsp;Since the original post, the TRIMMED option has been added to the INTO clause in PROC SQL to strip blanks:&lt;/P&gt;
&lt;PRE lang="sas"&gt;proc sql;&lt;BR /&gt;  select count(*) into :howmany trimmed from SASHELP.CLASS;&lt;BR /&gt;quit;&lt;BR /&gt;%put |&amp;amp;howmany|;&lt;BR /&gt;&lt;BR /&gt;|19|&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;
&lt;!-- Insert any appropriate category tags. Note that it is important to put the categorys inside the &lt;noinclude&gt; block so the categories are only applied to the tip page.- You can have as many CATEGORY tag lines as you want.--&gt;&lt;!-- Provide links to other resources:- If the links are pages on sasCommunity update the "WikiReadMore" line and replace "PAGENAME" with the name of the sasCommunity.org page.- If the links are external (e.g., the sas support site, other external links, and so on, updated the "External ReadMore" line and replace "URL" with the full url including the http:- You can include as many of these lines as you want- if you don't have such links, just delete the line(s)--&gt;&lt;!-- Please do not edit below this line, EXCEPT when promoting a tip --&gt;
&lt;DIV style="float: right;"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;See the documentation for the INTO clause &lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n1y2jszlvs4hugn14nooftfrxhp3.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;Thanks to Mike Zdeb&amp;nbsp;for sharing this tip on sasCommunity.org.&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2018 11:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Tips-from-the-Community/SAS-Tip-Strip-Blanks-from-PROC-SQL-Created-Macro-Variable-Values/m-p/442564#M169</guid>
      <dc:creator>SAS_Tipster</dc:creator>
      <dc:date>2018-05-12T11:22:40Z</dc:date>
    </item>
  </channel>
</rss>

