<?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: Run Macro from dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549581#M152507</link>
    <description>&lt;P&gt;Can you give us an example of what you are talking about?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "g:\myfolder\mymacro.sas";
data abc;
    %mymacro
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works if %MYMACRO produces valid data step code.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Apr 2019 13:23:05 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-04-09T13:23:05Z</dc:date>
    <item>
      <title>Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549577#M152505</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;I have stored Macro in data set I want run that macro .&lt;BR /&gt;Is there any way to run or compile that macro from SAS dataset.</description>
      <pubDate>Tue, 09 Apr 2019 13:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549577#M152505</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T13:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549581#M152507</link>
      <description>&lt;P&gt;Can you give us an example of what you are talking about?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you mean something like this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "g:\myfolder\mymacro.sas";
data abc;
    %mymacro
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This works if %MYMACRO produces valid data step code.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:23:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549581#M152507</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-09T13:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549584#M152508</link>
      <description>&lt;P&gt;I have already stored a macro code in a table now I have run that code.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:30:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549584#M152508</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T13:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549585#M152509</link>
      <description>&lt;P&gt;SAS macros are parts of &lt;EM&gt;program code&lt;/EM&gt;, not data, so you do not store them in SAS datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549585#M152509</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-09T13:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549587#M152510</link>
      <description>&lt;P&gt;I have already stored a macro in dataset now I want to run.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:28:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549587#M152510</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T13:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549588#M152511</link>
      <description>&lt;P&gt;Please post that dataset in a data step with datalines.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:29:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549588#M152511</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-09T13:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549593#M152514</link>
      <description>&lt;PRE&gt;Data m;
Length a $100;
a='%Macro Test;'; output;
a='data m; set sashelp.class; run;'; output;
a='%mend;'; output;
a='%Test'; output;
Run;&lt;/PRE&gt;&lt;P&gt;Let's suppose I have stored this macro in dataset now I have to call this macro.Is there any way to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:38:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549593#M152514</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T13:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549599#M152518</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206061"&gt;@akash1088&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;Data m;
Length a $100;
a='%Macro Test;'; output;
a='data m; set sashelp.class; run;'; output;
a='%mend;'; output;
a='%Test'; output;
Run;&lt;/PRE&gt;
&lt;P&gt;Let's suppose I have stored this macro in dataset now I have to call this macro.Is there any way to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I have never ever seen such an interesting approach to macro programming and after thinking about it, i can only advise: stop this right now! Macros are text and storing them in text-files is the only pain-free way to deal with them.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 13:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549599#M152518</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-04-09T13:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549608#M152522</link>
      <description>Actually I have many SAS code as a . SAS file but issues is that if I can't make changes in SAS code everytime so I am planning to store this Macro in permanent dataset and execute them .&lt;BR /&gt;&lt;BR /&gt;Is there any way to do that guys ?</description>
      <pubDate>Tue, 09 Apr 2019 13:58:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549608#M152522</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T13:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549610#M152524</link>
      <description>&lt;P&gt;If you have the source code for a macro definition in character variable(s) in a SAS dataset you have to get SAS to treat that as code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Say you have a dataset named HAVE with a variable named LINE that has the code as multiple lines of text.&lt;/P&gt;
&lt;P&gt;I think the easiest is to just write it to file and then %INCLUDE that file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename macdef temp;
data _null_;
  set have;
  file macdef;
  put line;
run;
%include macdef;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 14:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549610#M152524</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-09T14:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549613#M152525</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 14:06:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549613#M152525</guid>
      <dc:creator>akash1088</dc:creator>
      <dc:date>2019-04-09T14:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549614#M152526</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206061"&gt;@akash1088&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;Data m;
Length a $100;
a='%Macro Test;'; output;
a='data m; set sashelp.class; run;'; output;
a='%mend;'; output;
a='%Test'; output;
Run;&lt;/PRE&gt;
&lt;P&gt;Let's suppose I have stored this macro in dataset now I have to call this macro.Is there any way to do that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You should take&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt; advice.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It does seem to work using CALL EXECUTE and %NRSTR&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;75   %sysmacdelete test;
76   options mprint=1;
77   Data m;
78      Length a $100;
79      a='%Macro Test;'; output;
80      a='data m; set sashelp.class; put _all_; run;'; output;
81      a='%mend;'; output;
82      a='%Test'; output;
83      Run;

NOTE: The data set WORK.M has 4 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


84   proc print;
85      run;

NOTE: There were 4 observations read from the data set WORK.M.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


86   data _null_;
87      set m;
88      call execute(cats('%nrstr(',a,')'));
89      run;

NOTE: There were 4 observations read from the data set WORK.M.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


NOTE: CALL EXECUTE generated line.
1   + %Macro Test;
2   + data m; set sashelp.class; put _all_; run;
3   + %mend;
4   + %Test
MPRINT(TEST):   data m;
MPRINT(TEST):   set sashelp.class;
MPRINT(TEST):   put _all_;
MPRINT(TEST):   run;

Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 _ERROR_=0 _N_=1
Name=Alice Sex=F Age=13 Height=56.5 Weight=84 _ERROR_=0 _N_=2
Name=Barbara Sex=F Age=13 Height=65.3 Weight=98 _ERROR_=0 _N_=3
Name=Carol Sex=F Age=14 Height=62.8 Weight=102.5 _ERROR_=0 _N_=4
Name=Henry Sex=M Age=14 Height=63.5 Weight=102.5 _ERROR_=0 _N_=5
Name=James Sex=M Age=12 Height=57.3 Weight=83 _ERROR_=0 _N_=6
Name=Jane Sex=F Age=12 Height=59.8 Weight=84.5 _ERROR_=0 _N_=7
Name=Janet Sex=F Age=15 Height=62.5 Weight=112.5 _ERROR_=0 _N_=8
Name=Jeffrey Sex=M Age=13 Height=62.5 Weight=84 _ERROR_=0 _N_=9
Name=John Sex=M Age=12 Height=59 Weight=99.5 _ERROR_=0 _N_=10
Name=Joyce Sex=F Age=11 Height=51.3 Weight=50.5 _ERROR_=0 _N_=11
Name=Judy Sex=F Age=14 Height=64.3 Weight=90 _ERROR_=0 _N_=12
Name=Louise Sex=F Age=12 Height=56.3 Weight=77 _ERROR_=0 _N_=13
Name=Mary Sex=F Age=15 Height=66.5 Weight=112 _ERROR_=0 _N_=14
Name=Philip Sex=M Age=16 Height=72 Weight=150 _ERROR_=0 _N_=15
Name=Robert Sex=M Age=12 Height=64.8 Weight=128 _ERROR_=0 _N_=16
Name=Ronald Sex=M Age=15 Height=67 Weight=133 _ERROR_=0 _N_=17
Name=Thomas Sex=M Age=11 Height=57.5 Weight=85 _ERROR_=0 _N_=18
Name=William Sex=M Age=15 Height=66.5 Weight=112 _ERROR_=0 _N_=19
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.M has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Apr 2019 14:07:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549614#M152526</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-04-09T14:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Run Macro from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549630#M152531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/206061"&gt;@akash1088&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Actually I have many SAS code as a . SAS file but issues is that if I can't make changes in SAS code everytime so I am planning to store this Macro in permanent dataset and execute them .&lt;BR /&gt;&lt;BR /&gt;Is there any way to do that guys ?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you just want to bypass proper code maintenance processes?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Apr 2019 14:52:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-Macro-from-dataset/m-p/549630#M152531</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-09T14:52:32Z</dc:date>
    </item>
  </channel>
</rss>

