<?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: Basic SAS %macro question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402491#M97751</link>
    <description>the proc reg part of the macro works but not the proc print - does it matter if the proc print step is actually a data step: data &amp;amp;param; set &amp;amp;param;</description>
    <pubDate>Mon, 09 Oct 2017 19:46:42 GMT</pubDate>
    <dc:creator>Wafflecakes</dc:creator>
    <dc:date>2017-10-09T19:46:42Z</dc:date>
    <item>
      <title>Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401374#M97377</link>
      <description>&lt;P&gt;Good day all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Suppose I have a sas macro like so...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test&lt;/P&gt;&lt;P&gt;proc reg data=testing;&lt;/P&gt;&lt;P&gt;model y=x1 x2 x3;&lt;/P&gt;&lt;P&gt;output out=testing2&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc print data=testing2;&lt;/P&gt;&lt;P&gt;var x1 x2 x3&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to call the macro many, many times, but the 'testing2' output dataset is different each time I call it. How do I make this change?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:57:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401374#M97377</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-05T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401376#M97378</link>
      <description>&lt;P&gt;Your code has errors. I'm going to assume it's sample/representative code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a parameter to your macro definition that provides the data set name and then call the macro multiple times using CALL EXECUTE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or build an automatic DO loop into your macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are examples of either here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or search Lexjansen.com&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 15:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401376#M97378</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-05T15:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401380#M97379</link>
      <description>&lt;P&gt;You only use a macro if you need dynamic code. There is nothing dynamic in your example code.&lt;/P&gt;
&lt;P&gt;IF there is something in your &lt;EM&gt;real&lt;/EM&gt; code that needs to be made flexible, you can use the parameters used for that to name the output datasets in some way.&lt;/P&gt;
&lt;P&gt;Suppose this code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc reg data=testing;
model y=x1;
output out=testing1;
run;

proc print data=testing1;
var x1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;has to be made flexible, then you would do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test(param);

proc reg data=testing;
model y=x&amp;amp;param.;
output out=testing&amp;amp;param.;
run;

proc print data=testing&amp;amp;param.;
var x&amp;amp;param.;
run;

%mend;

%test(1)
%test(2)
%test(3)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Oct 2017 15:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/401380#M97379</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T15:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402469#M97736</link>
      <description>&lt;P&gt;Kurt - what if more thna 1 parameter needs to be made flexible?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 18:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402469#M97736</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T18:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402471#M97738</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161013"&gt;@Wafflecakes&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Kurt - what if more thna 1 parameter needs to be made flexible?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Use more macro parameters.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 18:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402471#M97738</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T18:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402473#M97739</link>
      <description>&lt;P&gt;%macro test(par, param);&lt;BR /&gt;proc reg data=testing;&lt;BR /&gt;model y=x;&lt;BR /&gt;where test=&amp;amp;par&lt;BR /&gt;output out=&amp;amp;param.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc print data=&amp;amp;param.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%test(1,1)&lt;BR /&gt;%test(2,2)&lt;BR /&gt;%test(3,3)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this correct?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively....&lt;/P&gt;&lt;P&gt;%test(1, linear1)&lt;/P&gt;&lt;P&gt;%test(2, linear2)&lt;/P&gt;&lt;P&gt;%test(3, linear3)&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402473#M97739</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T19:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402475#M97741</link>
      <description>Keep in mind the &amp;amp;par refers to the value of a variable in the dataset and &amp;amp;param refers to the name of an outputted dataset.</description>
      <pubDate>Mon, 09 Oct 2017 19:09:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402475#M97741</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T19:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402476#M97742</link>
      <description>&lt;P&gt;Your first version to call the macro won't work, as single digits are not valid as dataset names; your second version will work.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:11:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402476#M97742</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T19:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402477#M97743</link>
      <description>I got some output but the numbers are off.</description>
      <pubDate>Mon, 09 Oct 2017 19:12:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402477#M97743</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T19:12:20Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402480#M97744</link>
      <description>&lt;P&gt;If proc reg doesn't give you the results you expect, you should post that as question in the stat proc forum.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402480#M97744</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T19:16:03Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402485#M97747</link>
      <description>when you put &amp;amp;param and call %test(1,linear1), does the name of the dataset get called linear1 where &amp;amp;param first shows up and gets used in the subsequent proc print step as linear1?</description>
      <pubDate>Mon, 09 Oct 2017 19:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402485#M97747</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T19:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402488#M97749</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161013"&gt;@Wafflecakes&lt;/a&gt; wrote:&lt;BR /&gt;when you put &amp;amp;param and call %test(1,linear1), does the name of the dataset get called linear1 where &amp;amp;param first shows up and gets used in the subsequent proc print step as linear1?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If I read you right, yes. Use options symbolgen mprint mlogic; to show all macro activity in the log.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 19:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402488#M97749</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T19:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402491#M97751</link>
      <description>the proc reg part of the macro works but not the proc print - does it matter if the proc print step is actually a data step: data &amp;amp;param; set &amp;amp;param;</description>
      <pubDate>Mon, 09 Oct 2017 19:46:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402491#M97751</guid>
      <dc:creator>Wafflecakes</dc:creator>
      <dc:date>2017-10-09T19:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402507#M97754</link>
      <description>&lt;P&gt;Look at the log; you'll see which dataset is created by proc reg, and which one is used in proc print.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 20:42:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402507#M97754</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-09T20:42:08Z</dc:date>
    </item>
    <item>
      <title>Re: Basic SAS %macro question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402539#M97759</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161013"&gt;@Wafflecakes&lt;/a&gt; wrote:&lt;BR /&gt;&amp;nbsp;does it matter if the proc print step is actually a data step: data &amp;amp;param; set &amp;amp;param;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What? That doesn't make a lot of sense.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2017 23:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Basic-SAS-macro-question/m-p/402539#M97759</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-09T23:53:21Z</dc:date>
    </item>
  </channel>
</rss>

