<?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 based on 2 arguments from data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968314#M376523</link>
    <description>&lt;PRE&gt;Data MAcro_need_to_run;
infile datalines dsd;
input field $ Fmt $;
cards;
Wealth,F1MT
obligo,F2MT
LoansBal,F3Mt
;
Run;
&lt;STRONG&gt;data _null_;
set MAcro_need_to_run;
call execute(catt('%RRR(Var=',field,',Format=',fmt,')'));
run;&lt;/STRONG&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 06 Jun 2025 01:42:02 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-06-06T01:42:02Z</dc:date>
    <item>
      <title>Run macro based on 2 arguments from data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968305#M376521</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to create code that run macro based on 2 arguments from data set?&lt;/P&gt;
&lt;P&gt;The question is actually how to create this code austomatically?(In real word the data set includes many rows so I am looking for a way to run the macro from these values automatically)&lt;/P&gt;
&lt;P&gt;%RRR(VAR=Wealth ,Format=F1MT )&lt;BR /&gt;%RRR(VAR=obligo ,Format=F2MT )&lt;BR /&gt;%RRR(VAR=LoansBal ,Format=F3Mt )&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro RRR(VAR,Format);
proc sql;
create table a_dist_continuous as
select  Left("&amp;amp;VAR.") as Var_name  LENGTH=300,
       put(&amp;amp;VAR.,&amp;amp;Format.) as Cat LENGTH=100,
        count(*) as nr&amp;amp;mon.,
		calculated nr&amp;amp;mon./(select count(*) as total_nr from ttt) as tamhil&amp;amp;mon. format=percent8.2
from ttt
group by  calculated CAT
;
quit;
%mend RRR;

Data MAcro_need_to_run;
infile datalines dsd;
input field $ Fmt $;
cards;
Wealth,F1MT
obligo,F2MT
LoansBal,F3Mt
;
Run;



proc format;
value F1MT
.='(b1) NULL'
0='(b2) 0'
0&amp;lt;-1000='(b3) 0-1K'
1000&amp;lt;-5000='(b4) 1-5K'
5000&amp;lt;-High='(b5) 5K+'
Low-&amp;lt;0='(b6) Neg'
other='(b7) other'
;
Run;

proc format;
value F2MT
0-100='(b1) POS 0-100'
100&amp;lt;-High='(b2) POS 100+'
Low- -100='(b3) Neg_100+'
-100 - 0='(b4) Neg_0-100'
other='(b5) other'
;
Run;


proc  format;
value F3Mt
Low-0,.='(a1) 0/Null/Neg'
0&amp;lt;-High='(a2) Pos'
;
Run;


%RRR(VAR=Wealth  ,Format=F1MT )
%RRR(VAR=obligo  ,Format=F2MT )
%RRR(VAR=LoansBal  ,Format=F3Mt )


 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Jun 2025 21:11:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968305#M376521</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-06-05T21:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro based on 2 arguments from data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968314#M376523</link>
      <description>&lt;PRE&gt;Data MAcro_need_to_run;
infile datalines dsd;
input field $ Fmt $;
cards;
Wealth,F1MT
obligo,F2MT
LoansBal,F3Mt
;
Run;
&lt;STRONG&gt;data _null_;
set MAcro_need_to_run;
call execute(catt('%RRR(Var=',field,',Format=',fmt,')'));
run;&lt;/STRONG&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jun 2025 01:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968314#M376523</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-06-06T01:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Run macro based on 2 arguments from data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968320#M376526</link>
      <description>&lt;P&gt;To prevent the macro from executing while call execute is trying to stack up the code to run later make sure to add %nrstr() macro quoting.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(catt('%nrstr(%RRR)(Var=',field,',Format=',fmt,')'));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jun 2025 12:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Run-macro-based-on-2-arguments-from-data-set/m-p/968320#M376526</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-06-06T12:22:55Z</dc:date>
    </item>
  </channel>
</rss>

