<?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: Using MACRO without defining one of the macro variables? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71758#M20731</link>
    <description>Another Choice is to use call execute() ----My favorite.&lt;BR /&gt;
Which can generate code dynamically with your dataset.&lt;BR /&gt;
But firstly you need to transpose this dataset with proc transpose.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Thu, 02 Jun 2011 01:37:57 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-06-02T01:37:57Z</dc:date>
    <item>
      <title>Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71756#M20729</link>
      <description>I have a macro that is being run on several different user IDs, but I'd like to run the macro on the entire population as well.  Right now, the macro call uses the following variables:&lt;BR /&gt;
&lt;BR /&gt;
USER ID&lt;BR /&gt;
VAR1&lt;BR /&gt;
VAR2&lt;BR /&gt;
DATE1&lt;BR /&gt;
DATE2&lt;BR /&gt;
&lt;BR /&gt;
I'd like to run the macro on ALL USER IDs, so instead of my macro call being:&lt;BR /&gt;
%MACRO(132, ABC, DEF, JAN, FEB) what would I do to get it to run on all USER IDs?</description>
      <pubDate>Wed, 01 Jun 2011 14:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71756#M20729</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-06-01T14:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71757#M20730</link>
      <description>Depends on how you want to call it and what your macro does...&lt;BR /&gt;
&lt;BR /&gt;
1. Change your macro so that the first parameter is handled as a variable list&lt;BR /&gt;
2. Create another macro that loops through your list of ids in a dataset and calls the macro. &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
If you may want to do a few ID's at a time rather than a whole dataset you may want to consider 1 as the most viable option.</description>
      <pubDate>Wed, 01 Jun 2011 16:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71757#M20730</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-06-01T16:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71758#M20731</link>
      <description>Another Choice is to use call execute() ----My favorite.&lt;BR /&gt;
Which can generate code dynamically with your dataset.&lt;BR /&gt;
But firstly you need to transpose this dataset with proc transpose.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Thu, 02 Jun 2011 01:37:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71758#M20731</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-02T01:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71759#M20732</link>
      <description>my toolbag carries a macro I use for situations like this. I even presented it at a SAS conference &lt;BR /&gt;
"make light work of list processing"&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi31/012-31.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi31/012-31.pdf&lt;/A&gt;</description>
      <pubDate>Thu, 02 Jun 2011 11:35:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71759#M20732</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-02T11:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71760#M20733</link>
      <description>Is there a way to set the USER ID to a default value so that every single record has that value (basically making that field irrelevant) so I can run the macro on every single record?  I tried using the following code to do this, but I'm getting this error:&lt;BR /&gt;
&lt;BR /&gt;
%MACRO NAME(NAME,ID);&lt;BR /&gt;
&lt;BR /&gt;
%MACRO MONTH(month);&lt;BR /&gt;
&lt;BR /&gt;
data &amp;amp;NAME._&amp;amp;month.;&lt;BR /&gt;
set  all_&amp;amp;month._nores;&lt;BR /&gt;
%if "&amp;amp;NAME." eq "CONS" %then %do;&lt;BR /&gt;
USER_ID eq '888888888';&lt;BR /&gt;
%end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data &amp;amp;NAME._&amp;amp;month.;&lt;BR /&gt;
set  &amp;amp;NAME._&amp;amp;month.;&lt;BR /&gt;
if   USER_ID eq &amp;amp;ID.;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
%MEND MONTH;&lt;BR /&gt;
&lt;BR /&gt;
%MONTH(&amp;amp;cur_month.);&lt;BR /&gt;
%MONTH(&amp;amp;prev_month1.);&lt;BR /&gt;
%MONTH(&amp;amp;prev_month2.);&lt;BR /&gt;
%MONTH(&amp;amp;prev_month3.);&lt;BR /&gt;
%MONTH(&amp;amp;prev_month4.);&lt;BR /&gt;
%MONTH(&amp;amp;prev_month5.);&lt;BR /&gt;
&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
(it continues for a while, but the rest is unnecessary)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Here are a few of the Macro calls:&lt;BR /&gt;
&lt;BR /&gt;
%NAME(CONS,'888888888');&lt;BR /&gt;
%NAME(AH,'904029181');&lt;BR /&gt;
%NAME(BU,'903769181');&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Here is the log/error:&lt;BR /&gt;
&lt;BR /&gt;
1705  %NAME(CONS,'888888888');&lt;BR /&gt;
NOTE: Line generated by the invoked macro "MONTH".&lt;BR /&gt;
3      USER_ID eq '888888888'; &lt;BR /&gt;
       -----------------                &lt;BR /&gt;
       180                               &lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;
WARNING: The data set WORK.CONS_APR11 may be incomplete.  When this step was stopped there were 0&lt;BR /&gt;
         observations and 82 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.21 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 0 observations read from the data set WORK.CONS_APR11.&lt;BR /&gt;
NOTE: The data set WORK.CONS_APR11 has 0 observations and 82 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds</description>
      <pubDate>Thu, 02 Jun 2011 14:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71760#M20733</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-06-02T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71761#M20734</link>
      <description>I think you meant:&lt;BR /&gt;
&lt;BR /&gt;
%if "&amp;amp;NAME." eq "CONS" %then %do;&lt;BR /&gt;
USER_ID = '888888888'; /*assignment*/&lt;BR /&gt;
%end;&lt;BR /&gt;
&lt;BR /&gt;
instead of&lt;BR /&gt;
%if "&amp;amp;NAME." eq "CONS" %then %do;&lt;BR /&gt;
USER_ID eq '888888888'; /*comparison*/&lt;BR /&gt;
%end;</description>
      <pubDate>Thu, 02 Jun 2011 18:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71761#M20734</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-06-02T18:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using MACRO without defining one of the macro variables?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71762#M20735</link>
      <description>Yup, that was the problem!  Stupid mistake - thanks for pointing it out!</description>
      <pubDate>Thu, 02 Jun 2011 18:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-MACRO-without-defining-one-of-the-macro-variables/m-p/71762#M20735</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-06-02T18:26:22Z</dc:date>
    </item>
  </channel>
</rss>

