<?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: %EM_METACHANGE in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346847#M80026</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are wanting to call an already existing macro with values from a data set then the approach is likely to be CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;Perhaps:&lt;/P&gt;
&lt;PRE&gt;DATA _NULL_;
   SET DSet;
   Call execute( '%EM_METACHANGE (name ='|| variable_name||', level = ordinal);');
RUN;&lt;/PRE&gt;
&lt;P&gt;This is one time you don't want the macro inside double quotes because it will attempt to execute while the data step compiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that you have an existing macro %EM_METACHANGE that works correctly if you run it manually with the values of the variable.&lt;/P&gt;
&lt;P&gt;There is not need for Macro Test that I can see.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Apr 2017 21:49:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-03T21:49:02Z</dc:date>
    <item>
      <title>%EM_METACHANGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346843#M80024</link>
      <description>&lt;P&gt;Hello, good evening.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Imagine a dataset named DSet with one variable, that contains variable names:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------&lt;/P&gt;&lt;P&gt;variable_name&lt;/P&gt;&lt;P&gt;-------------------&lt;/P&gt;&lt;P&gt;income&lt;/P&gt;&lt;P&gt;interest&lt;/P&gt;&lt;P&gt;result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to transform this variables to level=ordinal, one by one.&lt;/P&gt;&lt;P&gt;So, I wrote this code inside an extended node.&lt;BR /&gt;I must say that this is inside a diagram with a strong legacy. I didn't build it but now I'm must maintain it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see m, I'm mixing macro code with names of dataset variable names ...&lt;/P&gt;&lt;P&gt;This isn't working ... possibilby due to this mess ...&amp;nbsp; &lt;STRONG&gt;name = variable_name&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can somebody help me, please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%&lt;/STRONG&gt;macro test;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET DSet;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %EM_METACHANGE (name = variable_name, level = ordinal);&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346843#M80024</guid>
      <dc:creator>rmlmrmlm</dc:creator>
      <dc:date>2017-04-03T21:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: %EM_METACHANGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346847#M80026</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are wanting to call an already existing macro with values from a data set then the approach is likely to be CALL EXECUTE.&lt;/P&gt;
&lt;P&gt;Perhaps:&lt;/P&gt;
&lt;PRE&gt;DATA _NULL_;
   SET DSet;
   Call execute( '%EM_METACHANGE (name ='|| variable_name||', level = ordinal);');
RUN;&lt;/PRE&gt;
&lt;P&gt;This is one time you don't want the macro inside double quotes because it will attempt to execute while the data step compiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that you have an existing macro %EM_METACHANGE that works correctly if you run it manually with the values of the variable.&lt;/P&gt;
&lt;P&gt;There is not need for Macro Test that I can see.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2017 21:49:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346847#M80026</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-03T21:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: %EM_METACHANGE</title>
      <link>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346863#M80027</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA _NULL_;
   SET DSet;
   call symputx('variable_name',variable_name);
   call symputx('ordinal',variable_name);
     rc=dosubl('
            %EM_METACHANGE (name = &amp;amp;variable_name, level = &amp;amp;ordinal);
     ');
RUN;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Apr 2017 23:40:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/EM-METACHANGE/m-p/346863#M80027</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-04-03T23:40:59Z</dc:date>
    </item>
  </channel>
</rss>

