<?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 Macro help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358363#M84182</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to call the macro variables values created by datastep(withoutmacro) where ever I can by calling "&amp;amp;b1,&amp;amp;c1,&amp;amp;d1,&amp;amp;e1".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the macro variables created by macro step(shown below), I am not able call the macro variables. When I use "&lt;SPAN&gt;&amp;amp;b1,&amp;amp;c1,&amp;amp;d1,&amp;amp;e1" in a datastep,the values of the macrovariables are not called&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help how can I use the macro variables created by the &amp;nbsp;macro step below. Thank you very much&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
input NS trt01a $ ;
datalines;
45 150MG
71 300MG
15 75MG
131 TOTAL
;
%macro two(var1=,var2=,var3=,var4=,var5=,var6=,var7=);
data &amp;amp;var2;
set &amp;amp;var1;
if trt01a='75MG' then trt="&amp;amp;var3";
if trt01a='150MG' then trt="&amp;amp;var4";
if trt01a='300MG' then trt="&amp;amp;var5";
if trt01a='TOTAL' then trt="&amp;amp;var6";
run;


data &amp;amp;var7;
set &amp;amp;var2;
call symputx(trt,ns);
run;
%mend;
%two(var1=one,var2=two,var3=b1,var4=c1,var5=d1,var6=f1,var7=three);&lt;/PRE&gt;
&lt;PRE&gt;data one;
input NS trt01a $ ;
datalines;
45 150MG
71 300MG
15 75MG
131 TOTAL
;&lt;BR /&gt;data withoutmacro; &lt;BR /&gt;set one;&lt;BR /&gt; if trt01a='75MG' then trt="b1"; &lt;BR /&gt;if trt01a='150MG' then trt="c1"; &lt;BR /&gt;if trt01a='300MG' then trt="d1"; &lt;BR /&gt;if trt01a='TOTAL' then trt="e1"; &lt;BR /&gt;run; &lt;BR /&gt;data withoutmacro1; &lt;BR /&gt;set withoutmacro; &lt;BR /&gt;call symputx(trt,ns); &lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 22:21:45 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2017-05-12T22:21:45Z</dc:date>
    <item>
      <title>Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358363#M84182</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to call the macro variables values created by datastep(withoutmacro) where ever I can by calling "&amp;amp;b1,&amp;amp;c1,&amp;amp;d1,&amp;amp;e1".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the macro variables created by macro step(shown below), I am not able call the macro variables. When I use "&lt;SPAN&gt;&amp;amp;b1,&amp;amp;c1,&amp;amp;d1,&amp;amp;e1" in a datastep,the values of the macrovariables are not called&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help how can I use the macro variables created by the &amp;nbsp;macro step below. Thank you very much&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
input NS trt01a $ ;
datalines;
45 150MG
71 300MG
15 75MG
131 TOTAL
;
%macro two(var1=,var2=,var3=,var4=,var5=,var6=,var7=);
data &amp;amp;var2;
set &amp;amp;var1;
if trt01a='75MG' then trt="&amp;amp;var3";
if trt01a='150MG' then trt="&amp;amp;var4";
if trt01a='300MG' then trt="&amp;amp;var5";
if trt01a='TOTAL' then trt="&amp;amp;var6";
run;


data &amp;amp;var7;
set &amp;amp;var2;
call symputx(trt,ns);
run;
%mend;
%two(var1=one,var2=two,var3=b1,var4=c1,var5=d1,var6=f1,var7=three);&lt;/PRE&gt;
&lt;PRE&gt;data one;
input NS trt01a $ ;
datalines;
45 150MG
71 300MG
15 75MG
131 TOTAL
;&lt;BR /&gt;data withoutmacro; &lt;BR /&gt;set one;&lt;BR /&gt; if trt01a='75MG' then trt="b1"; &lt;BR /&gt;if trt01a='150MG' then trt="c1"; &lt;BR /&gt;if trt01a='300MG' then trt="d1"; &lt;BR /&gt;if trt01a='TOTAL' then trt="e1"; &lt;BR /&gt;run; &lt;BR /&gt;data withoutmacro1; &lt;BR /&gt;set withoutmacro; &lt;BR /&gt;call symputx(trt,ns); &lt;BR /&gt;run;&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 22:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358363#M84182</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-12T22:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358368#M84186</link>
      <description>&lt;P&gt;You didn't show any code where you were attempting to apply macro variables outside of the macro, thus we can only guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Possibly, you simply have to define the macro variables you want to use outside of the macro as GLOBAL. Otherwise, they will simply be local to the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 22:33:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358368#M84186</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-05-12T22:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358381#M84192</link>
      <description>&lt;P&gt;I think you need to start over. I would bet money on the method you're using here is inefficient and clunky. It looks like you're trying to transpose/recode using macros when other options are probably better.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you start from scratch by posting what you have and what you need? Make it small/simple enough to use on the forum, but complex enough to capture all your requirements.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 23:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358381#M84192</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-12T23:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358391#M84202</link>
      <description>&lt;P&gt;Works fine for me.&lt;/P&gt;
&lt;PRE&gt;2317  data one;
2318  input NS trt01a $ ;
2319  datalines;

NOTE: The data set WORK.ONE has 4 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


2324  ;
2325  data withoutmacro;
2326    set one;
2327    if trt01a='75MG' then trt="b1";
2328    if trt01a='150MG' then trt="c1";
2329    if trt01a='300MG' then trt="d1";
2330    if trt01a='TOTAL' then trt="e1";
2331    call symputx(trt,ns);
2332  run;

NOTE: There were 4 observations read from the data set WORK.ONE.
NOTE: The data set WORK.WITHOUTMACRO has 4 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


2333
2334  %put &amp;amp;=b1 &amp;amp;=c1 &amp;amp;=d1 &amp;amp;=e1;
B1=15 C1=45 D1=71 E1=131
&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 May 2017 00:05:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358391#M84202</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-13T00:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358410#M84209</link>
      <description>&lt;P&gt;Thank you very much for the reply. Some one suggested me to use "%global b1 c1 d1 f1;" in the macro. I think I got my answer. Thank you very much for the outstanding support&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 02:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358410#M84209</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-13T02:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358411#M84210</link>
      <description>&lt;P&gt;Thank you very much. % global statemnt worked. &amp;nbsp;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 13 May 2017 02:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358411#M84210</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-13T02:21:42Z</dc:date>
    </item>
  </channel>
</rss>

