<?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 Breaking out the SAS macro constraints - is this possible? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99813#M21000</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been given a database in which each 'root' variable has 94 variants, with suffixes running from A to CP (don't ask why - unfortunately it's not something I can change).&amp;nbsp;&amp;nbsp; So for instance, there may exist a 'root' variable called "result", for which in the dataset there exist 94 fields resulta, resultb, ...., resultcp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very often I want to drop many of these variables, but not all.&amp;nbsp; I would like to be able to specify a range of variables to drop.&amp;nbsp; The syntax I would like would be something like:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop = %dropvars(result, 3,5)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which would output &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop = resultc resultd resulte&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I realise that if these variables were contiguous in the dataset, i could specify the range directly.&amp;nbsp; However,&amp;nbsp; I cannot guarantee they will be contiguous, so I need another option..)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Achieving the string "resultc resultd resulte"&amp;nbsp; in a macro variable is relatively easy.&amp;nbsp; For instance, I have a table called suffixes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i suffix&lt;/P&gt;&lt;P&gt;1 a&lt;/P&gt;&lt;P&gt;2 b&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;94 cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can then just do something like:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select suffix&lt;/P&gt;&lt;P&gt;into :suffixlist separated by " "&lt;/P&gt;&lt;P&gt;from suffixes&lt;/P&gt;&lt;P&gt;where i &amp;gt; start and &amp;lt; end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if this code were part of a macro it gets outputted when I call the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's therefore not possible to use the macro in code like:&lt;/P&gt;&lt;P&gt;data datadropped;&lt;/P&gt;&lt;P&gt;set database (drop = %dropvars(result, 3,5) );&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are various getarounds to this problem, one of which I have successfully implemented.&amp;nbsp; Basically, this solution involves running the proc sqls first to create macro variables containing the variables to drop, and then using these macro variables in the drop statement.&amp;nbsp; However, it's nowhere near as 'clean' as the code I would like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way around this, or is what I want to achieve simply antithetical to the SAS macro system?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much for any help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Apr 2013 11:08:57 GMT</pubDate>
    <dc:creator>RobinL</dc:creator>
    <dc:date>2013-04-06T11:08:57Z</dc:date>
    <item>
      <title>Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99813#M21000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have been given a database in which each 'root' variable has 94 variants, with suffixes running from A to CP (don't ask why - unfortunately it's not something I can change).&amp;nbsp;&amp;nbsp; So for instance, there may exist a 'root' variable called "result", for which in the dataset there exist 94 fields resulta, resultb, ...., resultcp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very often I want to drop many of these variables, but not all.&amp;nbsp; I would like to be able to specify a range of variables to drop.&amp;nbsp; The syntax I would like would be something like:&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop = %dropvars(result, 3,5)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which would output &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop = resultc resultd resulte&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(I realise that if these variables were contiguous in the dataset, i could specify the range directly.&amp;nbsp; However,&amp;nbsp; I cannot guarantee they will be contiguous, so I need another option..)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Achieving the string "resultc resultd resulte"&amp;nbsp; in a macro variable is relatively easy.&amp;nbsp; For instance, I have a table called suffixes:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i suffix&lt;/P&gt;&lt;P&gt;1 a&lt;/P&gt;&lt;P&gt;2 b&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;94 cp&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can then just do something like:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select suffix&lt;/P&gt;&lt;P&gt;into :suffixlist separated by " "&lt;/P&gt;&lt;P&gt;from suffixes&lt;/P&gt;&lt;P&gt;where i &amp;gt; start and &amp;lt; end;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, if this code were part of a macro it gets outputted when I call the macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's therefore not possible to use the macro in code like:&lt;/P&gt;&lt;P&gt;data datadropped;&lt;/P&gt;&lt;P&gt;set database (drop = %dropvars(result, 3,5) );&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are various getarounds to this problem, one of which I have successfully implemented.&amp;nbsp; Basically, this solution involves running the proc sqls first to create macro variables containing the variables to drop, and then using these macro variables in the drop statement.&amp;nbsp; However, it's nowhere near as 'clean' as the code I would like.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way around this, or is what I want to achieve simply antithetical to the SAS macro system?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much for any help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 11:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99813#M21000</guid>
      <dc:creator>RobinL</dc:creator>
      <dc:date>2013-04-06T11:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99814#M21001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Since your lookup data resides in a table, it's hard for you to reach that information using an in-line macro.&lt;/P&gt;&lt;P&gt;One quite easy compromise would be to have your SQL executed first, without the where-clause, then have your in-line macro navigate in the resulting macro variable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 12:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99814#M21001</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2013-04-06T12:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99815#M21002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just put the lookup table in a macro variable.&amp;nbsp; It can be in the macro or global.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;17&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dropvars(root,b,e);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;18&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; suffix i;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;19&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; suffix = a b c d e f g &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;...&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; ac;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; i = &amp;amp;b &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &amp;amp;e; &amp;amp;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;root.&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&amp;amp;suffix,&amp;amp;i,&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&lt;/SPAN&gt; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;21&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dropvars;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;22&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: %&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM style="color: #000000; background-color: #ffffff;"&gt;dropvars&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(result, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;5&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000; background-color: #ffffff;"&gt;resultc&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; resultd resulte&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 12:40:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99815#M21002</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-04-06T12:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99816#M21003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is another version that uses the suffix as the arguments not the index.&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;24&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; background-color: #ffffff;"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dropvars(root,arg1,arg2);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;25&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; suffix _i _w;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;26&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; suffix = a b c d e f g h i j k &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; ac;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;27&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _i = &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%to&lt;/SPAN&gt; &lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;10&lt;/STRONG&gt;&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;28&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&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; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _w = &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&amp;amp;suffix,&amp;amp;_i,&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&lt;/SPAN&gt; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;29&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&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; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%local&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &amp;amp;_w;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;30&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&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; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &amp;amp;_w = &amp;amp;_i;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;31&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&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; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;32&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; _i = &amp;amp;&amp;amp;&amp;amp;arg1 &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%to&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; &amp;amp;&amp;amp;&amp;amp;arg2; &amp;amp;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;root.&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%scan&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&amp;amp;suffix,&amp;amp;_i,&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(&lt;/SPAN&gt; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; background-color: #ffffff;"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dropvars;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;&lt;STRONG&gt;34&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: %&lt;/SPAN&gt;&lt;STRONG style="color: #000000; background-color: #ffffff;"&gt;&lt;EM&gt;dropvars&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;(result,c,i);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: &lt;/SPAN&gt;&lt;SPAN style="color: #ff0000; background-color: #ffffff;"&gt;resultc&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; resultd resulte resultf resultg resulth resulti&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 13:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99816#M21003</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-04-06T13:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99817#M21004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is possible to read from a dataset in a macro.&amp;nbsp; You can use %SYSCALL SET() function to link the dataset variables to macro variables so that you can fetch the observations from the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data suffixes;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; input i suffix $ @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;1 a 2 b 3 c 4 d &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;94 cp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%macro dropvars(prefix,values);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%local i suffix rc did ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%let did=%sysfunc(open(suffixes(where=(i in (&amp;amp;values))))) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%if &amp;amp;did %then %do;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %syscall set(did);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%* Note the single space between end of the do statement and macro variable expansion ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; %do %while (not %sysfunc(fetch(&amp;amp;did)));&lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt; &amp;amp;prefix.%trim(&amp;amp;suffix) %end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier; font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; %let rc=%sysfunc(close(&amp;amp;did));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%mend dropvars;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;%put %dropvars(RESULT,1 3 4);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 15:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99817#M21004</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2013-04-06T15:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Breaking out the SAS macro constraints - is this possible?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99818#M21005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks all for your input.&amp;nbsp; I've not explored macro functions in as much depth as I should have.&amp;nbsp; Once i've seen how to do it it seems obvious: if you want a sas macro that performs calculations but only outputs the results of those calculations, you need to be using macro functions rather than performing the calculations in base SAS code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Apr 2013 18:51:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Breaking-out-the-SAS-macro-constraints-is-this-possible/m-p/99818#M21005</guid>
      <dc:creator>RobinL</dc:creator>
      <dc:date>2013-04-06T18:51:04Z</dc:date>
    </item>
  </channel>
</rss>

