<?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: Need help on macro variable created from into: clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127163#M25920</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Just try to assign like this.&lt;/P&gt;&lt;P&gt;%let nn=&amp;amp;n;&lt;/P&gt;&lt;P&gt;retain form_1-form_&amp;amp;nn;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Nov 2012 12:39:47 GMT</pubDate>
    <dc:creator>shivas</dc:creator>
    <dc:date>2012-11-15T12:39:47Z</dc:date>
    <item>
      <title>Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127162#M25919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi SASians,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've a macro variable created with an into: clause from a max(count(*)) function using PROC SQL. When I invoke the same variable for a variable list decleration I end up with error messages as below&lt;/P&gt;&lt;P&gt;SYMBOLGEN:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Macro variable N resolves to&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P&gt;705&lt;/P&gt;&lt;P&gt;ERROR:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Missing numeric suffix on a numbered variable list (FORM_1-FORM_).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code used for macro var creation is&lt;/P&gt;&lt;P&gt;Proc SQL;&lt;/P&gt;&lt;P&gt;SELECT max(maxi) into : n from&lt;/P&gt;&lt;P&gt;( select id_var, count(*) as maxi from prim_tab);&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;P&gt;The above variable is invoked in a retain statement as below&lt;/P&gt;&lt;P&gt;RETAIN FORM_1 - FORM_&amp;amp;n;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like the macro var is generated with spaces to the left and hence the above error. Usually Count function should retrieve numeric datatype values and this shouldnt be an issue. But as I'm surprised to find such error. Any solutions and support will be highly appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 12:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127162#M25919</guid>
      <dc:creator>pawan</dc:creator>
      <dc:date>2012-11-15T12:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127163#M25920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Just try to assign like this.&lt;/P&gt;&lt;P&gt;%let nn=&amp;amp;n;&lt;/P&gt;&lt;P&gt;retain form_1-form_&amp;amp;nn;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Shiva&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 12:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127163#M25920</guid>
      <dc:creator>shivas</dc:creator>
      <dc:date>2012-11-15T12:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127164#M25921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SAS does an automatic number to character conversion using BEST12 format.&amp;nbsp; That gives you the leading blanks. &lt;/P&gt;&lt;P&gt;You can emulate trimming by just writing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let n = &amp;amp;n ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case SAS will skip the multiple blanks in the resolved value and store it in a macro variable with the same name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you can be a purist and in your SQL have&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select trim(left(put(&lt;EM&gt;value&lt;/EM&gt;, best.))) into :n&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Richard in Oz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 12:52:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127164#M25921</guid>
      <dc:creator>RichardinOz</dc:creator>
      <dc:date>2012-11-15T12:52:39Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127165#M25922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or less wording:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select cats(value) into :n&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 14:08:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127165#M25922</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-11-15T14:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127166#M25923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Richard, it worked. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 15:25:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127166#M25923</guid>
      <dc:creator>pawan</dc:creator>
      <dc:date>2012-11-15T15:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127167#M25924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A trick can be to use &lt;EM&gt;separated by&lt;/EM&gt; to automatically trim the value, which will work regardless of a numeric or character value.&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;SELECT max(maxi) into : n separated by ' ' from&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;( select id_var, count(*) as maxi from prim_tab);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;QUIT;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;And following onto Richards example, strip() would work just as well. Regardless, it may not be a bad idea to use a put() statement to control the data value format being stored in the macro variable. Have attached some examples as the effect is interesting and &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;all the extra spaces in ex3 is not a typo. &lt;/SPAN&gt;.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(age) into: ex1 from sashelp.class ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(age) into: ex2 separated by ' ' from sashelp.class ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select cats(max(age)) into: ex3 from sashelp.class ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select put(max(age), 8.-L) into: ex4 from sashelp.class ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%put [&amp;amp;ex1];&lt;/P&gt;&lt;P&gt;%put [&amp;amp;ex2];&lt;/P&gt;&lt;P&gt;%put [&amp;amp;ex3];&lt;/P&gt;&lt;P&gt;%put [&amp;amp;ex4];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would give the following in the log&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;32&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;&lt;P&gt;33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(age) into: ex1 from sashelp.class ;&lt;/P&gt;&lt;P&gt;34&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select max(age) into: ex2 separated by ' ' from sashelp.class ;&lt;/P&gt;&lt;P&gt;35&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select cats(max(age)) into: ex3 from sashelp.class ;&lt;/P&gt;&lt;P&gt;36&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select put(max(age), 8.-L) into: ex4 from sashelp.class ;&lt;/P&gt;&lt;P&gt;37&lt;/P&gt;&lt;P&gt;38&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;39&lt;/P&gt;&lt;P&gt;40&amp;nbsp;&amp;nbsp; %put [&amp;amp;ex1];&lt;/P&gt;&lt;P&gt;[&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 16]&lt;/P&gt;&lt;P&gt;41&amp;nbsp;&amp;nbsp; %put [&amp;amp;ex2];&lt;/P&gt;&lt;P&gt;[16]&lt;/P&gt;&lt;P&gt;42&amp;nbsp;&amp;nbsp; %put [&amp;amp;ex3];&lt;/P&gt;&lt;P&gt;[16&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ]&lt;/P&gt;&lt;P&gt;43&amp;nbsp;&amp;nbsp; %put [&amp;amp;ex4];&lt;/P&gt;&lt;P&gt;[16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ]&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;HTH&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 16:52:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127167#M25924</guid>
      <dc:creator>MagnusMengelbier</dc:creator>
      <dc:date>2012-11-15T16:52:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127168#M25925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oooo!! Lovely show!! Thanks a lot... and thanks all..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 18:04:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127168#M25925</guid>
      <dc:creator>pawan</dc:creator>
      <dc:date>2012-11-15T18:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127169#M25926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you are using SAS 9.3 you can use the open-ended macro range technique as described in Chris Hemedinger's blog post... &lt;A class="active_link" href="http://blogs.sas.com/content/sasdummy/2012/03/23/improving-on-a-sas-programming-pattern/" title="http://blogs.sas.com/content/sasdummy/2012/03/23/improving-on-a-sas-programming-pattern/"&gt; Improving on a SAS programming pattern - The SAS Dummy&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using this technique eliminates the need for the first SQL query to get the number of observations into a macro variable as you don't need to in SAS 9.3 and the macro variable values are trimmed as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Michelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Nov 2012 19:11:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127169#M25926</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2012-11-15T19:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help on macro variable created from into: clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127170#M25927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;one more way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RETAIN FORM_1 - FORM_%left(&amp;amp;n)&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Nov 2012 03:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-on-macro-variable-created-from-into-clause/m-p/127170#M25927</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-11-16T03:16:49Z</dc:date>
    </item>
  </channel>
</rss>

