<?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: How do you compress a macro variable created from within PROC SQL in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177028#M45356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When the datalines change to all single digits, for instance, then the best7. format still pads 6 spaces.&amp;nbsp; To compress the resulting macro variable I found Hai.kuo's use of separated by 'anything' to do the trick.&amp;nbsp; But thanks for the quick reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 12 Jul 2014 06:57:11 GMT</pubDate>
    <dc:creator>DataMatt</dc:creator>
    <dc:date>2014-07-12T06:57:11Z</dc:date>
    <item>
      <title>How do you compress a macro variable created from within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177025#M45353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't seem to remove trailing spaces in a macro variable created from within PROC SQL.&amp;nbsp; A LENGTH can be assigned to the variable in the SELECT statement to force the effect but only if I know the length ahead of time does that make sense to do.&amp;nbsp; The same situation for text variables.&amp;nbsp; I have been creating the data set variable in PROC SQL and then using a DATA step with CALL SYMPUT to create the macro variable.&amp;nbsp; That works but adds unnecessary lines of code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the new code I want to use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA d20140711; INPUT VAR1; DATALINES;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;P&gt;4000&lt;/P&gt;&lt;P&gt;50000&lt;/P&gt;&lt;P&gt;; RUN;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;/P&gt;&lt;P&gt; SELECT COMPRESS(PUT(AVG(VAR1), BEST.), ' ')&lt;/P&gt;&lt;P&gt; INTO : VAR1_AVG&lt;/P&gt;&lt;P&gt; FROM d20140711;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT [VAR1_AVG=&amp;amp;VAR1_AVG];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SAS log contains this text:&amp;nbsp; [VAR1_AVG=10864.2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jul 2014 02:48:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177025#M45353</guid>
      <dc:creator>DataMatt</dc:creator>
      <dc:date>2014-07-12T02:48:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compress a macro variable created from within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177026#M45354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are many ways (almost too many IMO) to eliminate the blanks, the following is the copy - paste version credited to @Tom,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql noprint ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;select max(age) into :a1 from sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;4&amp;nbsp;&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;%let a1=&amp;amp;a1;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;6&amp;nbsp;&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;7&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;select max(age) into :a1 - :a1 from sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;9&amp;nbsp;&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;select max(age) into :a1 separated by 'anything' from sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;12&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;13&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;14&amp;nbsp;&amp;nbsp; * SAS 9.3 or higher ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;15&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;select max(age) into :a1 -&amp;nbsp; from sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;16&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;17&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;select max(age) into :a1 trimmed from sashelp.class;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;19&amp;nbsp;&amp;nbsp; %put a1=|&amp;amp;a1|;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;a1=|16|&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;20&amp;nbsp;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;The original link is as: &lt;A __default_attr="177821" __jive_macro_name="message" class="jive_macro jive_macro_message active_link" href="https://communities.sas.com/" modifiedtitle="true" title="Re: Using Macro variables to define a variable list"&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;Regards,&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: 'courier new', courier;"&gt;Haikuo&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jul 2014 03:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177026#M45354</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2014-07-12T03:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compress a macro variable created from within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177027#M45355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA d20140711; INPUT VAR1; DATALINES;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;P&gt;4000&lt;/P&gt;&lt;P&gt;50000&lt;/P&gt;&lt;P&gt;; RUN;&lt;/P&gt;&lt;P&gt;PROC SQL NOPRINT;&lt;/P&gt;&lt;P&gt;SELECT COMPRESS(PUT(AVG(VAR1),BEST7.),' ') INTO:VAR1_AVG FROM d20140711;&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;%PUT [VAR1_AVG=&amp;amp;VAR1_AVG];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The SAS log contains this text:&lt;/SPAN&gt; [VAR1_AVG=10864.2]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jul 2014 03:53:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177027#M45355</guid>
      <dc:creator>nirugh4846</dc:creator>
      <dc:date>2014-07-12T03:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compress a macro variable created from within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177028#M45356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When the datalines change to all single digits, for instance, then the best7. format still pads 6 spaces.&amp;nbsp; To compress the resulting macro variable I found Hai.kuo's use of separated by 'anything' to do the trick.&amp;nbsp; But thanks for the quick reply.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jul 2014 06:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177028#M45356</guid>
      <dc:creator>DataMatt</dc:creator>
      <dc:date>2014-07-12T06:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compress a macro variable created from within PROC SQL</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177029#M45357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And you also can use %left( &amp;amp;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VAR1_AVG&lt;/SPAN&gt; )&amp;nbsp;&amp;nbsp; %trim(&amp;amp;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;VAR1_AVG&lt;/SPAN&gt;) to avoid these annoying blanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Jul 2014 12:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-do-you-compress-a-macro-variable-created-from-within-PROC/m-p/177029#M45357</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2014-07-12T12:17:09Z</dc:date>
    </item>
  </channel>
</rss>

