<?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: Macro help in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358178#M84143</link>
    <description>&lt;P&gt;Sorry, what is it your actually trying to do as to me this code doesn't do anything? &amp;nbsp;Post example test data in a datastep and what you want out. &amp;nbsp;A simple datastep should be able to list out the treatments??&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2017 08:29:40 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-05-12T08:29:40Z</dc:date>
    <item>
      <title>Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358123#M84126</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;I have a question in this macro which I am using. The macro gives me output I need. But my question is about "%put &amp;amp;b1 &amp;amp;c1 &amp;amp;d1 &amp;nbsp;&amp;amp;f1;" statement in the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I put "%put &amp;amp;b1 &amp;amp;c1 &amp;amp;d1 &amp;nbsp;&amp;amp;f1;" &amp;nbsp;statement in the macro it shows numerical numbers in the log which exactly the I am expecting&lt;/P&gt;
&lt;P&gt;But when I use this &amp;nbsp;"%put &amp;amp;var6 &amp;amp;var7 &amp;amp;var8 &amp;nbsp;&amp;amp;var9; " &amp;nbsp;statement it shows 'b1' &amp;nbsp;'c1' 'd1' 'f1' in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please suggest how should I get the output in the logI got when i used &amp;nbsp;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;%put &amp;amp;b1 &amp;amp;c1 &amp;amp;d1 &amp;nbsp;&amp;amp;f1;" statement IN THE MACRO.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am planning to use&amp;nbsp;"%put &amp;amp;var6 &amp;amp;var7 &amp;amp;var8 &amp;nbsp;&amp;amp;var9; statement instead of&amp;nbsp;"%put &amp;amp;b1 &amp;amp;c1 &amp;amp;d1 &amp;nbsp;&amp;amp;f1;" statement as the values change for my next table&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you very much.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro three(var1=,var2=,var3=,var4=,var5=,var6=,var7=,var8=,var9=); 

data &amp;amp;var1(keep=usubjid trt01a);
length TRT01A $50.;
set adsl;
if &amp;amp;var2;
if trt01a in ('JZP-110 75mg' 'JZP-110 150mg' 'JZP-110 300mg');
format trt01a $trta.;
run;

proc sql;
create table &amp;amp;var3 as
select count(distinct usubjid) as NS,TRT01A
from &amp;amp;var1
group by TRT01A;
quit; 

data &amp;amp;var4;
set &amp;amp;var3;
trt01a=strip(trt01a);
if trt01a='JZP-110 75mg' then trt=&amp;amp;var6;
if trt01a='JZP-110 150mg' then trt=&amp;amp;var7;
if trt01a='JZP-110 300mg' then trt=&amp;amp;var8;
run;

data &amp;amp;var5;
set &amp;amp;var4 end=done;
if trt01a in ('JZP-110 150mg', 'JZP-110 300mg', 'JZP-110 75mg' ) then Total + ns;
output;
if done;
ns = TOTAL;
trt=&amp;amp;var9;
trt01a='Total';
output;
drop Total;
run;

data _null_;
set &amp;amp;var5;
call symputx(trt,ns);
run;

&lt;FONT color="#800000"&gt;%put &amp;amp;b1 &amp;amp;c1 &amp;amp;d1  &amp;amp;f1;&lt;BR /&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#800000"&gt;%put &amp;amp;var6 &amp;amp;var7 &amp;amp;var8  &amp;amp;var9;&lt;BR /&gt;&lt;/FONT&gt;%mend; &lt;BR /&gt;&lt;BR /&gt;%three(var1=adsl1,var2=saffl="Y",var3=TNSTFD,var4=tnstfd1,var5=tnstfd11,var6='b1',var7='c1',var8='d1',var9='f1');&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 05:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358123#M84126</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-12T05:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358127#M84128</link>
      <description>&lt;P&gt;Looking quickly at your macro it is clear that the macro variables VAR1, VAR2, etc have the names of DATASETS. So of course when you ask SAS to print the values of the macro variables it will print those data set names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what do you want it to do instead?&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 05:14:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358127#M84128</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-12T05:14:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358130#M84129</link>
      <description>&lt;P&gt;It's very difficult to guess what you are after from what you posted.&lt;/P&gt;
&lt;P&gt;You are not helping yourself at all here by putting so little effort into this post.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe that's what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
  %let b1=1;
  %let c1=1;
  %let d1=1;
  %let f1=1;
  data ADSL; retain USUBJID TRT01A SAFFL ' '; run;

%macro three(var1=,var2=,var3=,var4=,var5=,var6=,var7=,var8=,var9=); 
%macro _;%mend _;
data &amp;amp;var1(keep=usubjid trt01a);
  length TRT01A $50.;
  set adsl;
  if &amp;amp;var2;
  if trt01a in ('JZP-110 75mg' 'JZP-110 150mg' 'JZP-110 300mg');
  *format trt01a $trta.;
run;

proc sql;
  create table &amp;amp;var3 as
  select count(distinct usubjid) as NS,TRT01A
  from &amp;amp;var1
  group by TRT01A;
quit; 

data &amp;amp;var4;
  set &amp;amp;var3;
  trt01a=strip(trt01a);
  if trt01a='JZP-110 75mg'  then trt="&amp;amp;var6";
  if trt01a='JZP-110 150mg' then trt="&amp;amp;var7";
  if trt01a='JZP-110 300mg' then trt="&amp;amp;var8";
run;

data &amp;amp;var5;
  set &amp;amp;var4 end=done;
  if trt01a in ('JZP-110 150mg', 'JZP-110 300mg', 'JZP-110 75mg' ) then Total + ns;
  output;
  if done;
  ns = TOTAL;
  trt="&amp;amp;var9";
  trt01a='Total';
  output;
  drop Total;
  call symputx(trt,ns);
run;

%put 1- &amp;amp;b1 &amp;amp;c1 &amp;amp;d1 &amp;amp;f1;

%put 2- &amp;amp;&amp;amp;&amp;amp;var6 &amp;amp;&amp;amp;&amp;amp;var7 &amp;amp;&amp;amp;&amp;amp;var8 &amp;amp;&amp;amp;&amp;amp;var9;
%mend; 

%three(var1=adsl1,var2=saffl="Y",var3=TNSTFD,var4=tnstfd1,var5=tnstfd11
,var6=b1,var7=c1,var8=d1,var9=f1);
 &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;1- 1 1 1 1&lt;BR /&gt;2- 1 1 1 1&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 05:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358130#M84129</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-05-12T05:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358139#M84131</link>
      <description>&lt;P&gt;Thank you very much for your time. Bellow is the short explanation what I am looking. If this is not clear, I am very sorry. I will try to put my question better way next time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Beofore I created the macro, I used to ran "&lt;SPAN&gt;%put &amp;amp;b &amp;amp;c &amp;amp;d &amp;amp;f;" statement at the end to check the numbers.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now I created a macro which includes same code as I will be running on different tables . My question is, &amp;nbsp;If I want to check the numbers as before &amp;nbsp;what statement should i include in the macro&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#993300"&gt;data _null_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;set tnstfd11;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;call symputx(trt,ns);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%put &amp;amp;b &amp;amp;c &amp;amp;d &amp;amp;f;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358139#M84131</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-12T06:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358143#M84133</link>
      <description>&lt;P&gt;Does my code yield the result that you expect when you run it?&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 06:04:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358143#M84133</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-05-12T06:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358178#M84143</link>
      <description>&lt;P&gt;Sorry, what is it your actually trying to do as to me this code doesn't do anything? &amp;nbsp;Post example test data in a datastep and what you want out. &amp;nbsp;A simple datastep should be able to list out the treatments??&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 08:29:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358178#M84143</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-12T08:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358204#M84150</link>
      <description>&lt;P&gt;var6 to var9 contain the macro variable names you want to use in thge data _null_ step. Since you never reset those variables, their content will stay as it is. If you want to display the content of a macro variable that is referenced by another macro variable, use a double ampersand.&lt;/P&gt;
&lt;P&gt;To facilitate that, get rid of the quotes:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%three(var1=adsl1,var2=saffl="Y",var3=TNSTFD,var4=tnstfd1,var5=tnstfd11,var6=b1,var7=c1,var8=d1,var9=f1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Next, change the way you use those macrovars:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data &amp;amp;var4;
set &amp;amp;var3;
trt01a=strip(trt01a);
if trt01a='JZP-110 75mg' then trt="&amp;amp;var6";
if trt01a='JZP-110 150mg' then trt="&amp;amp;var7";
if trt01a='JZP-110 300mg' then trt="&amp;amp;var8";
run;

data &amp;amp;var5;
set &amp;amp;var4 end=done;
if trt01a in ('JZP-110 150mg', 'JZP-110 300mg', 'JZP-110 75mg' ) then Total + ns;
output;
if done;
ns = TOTAL;
trt="&amp;amp;var9";
trt01a='Total';
output;
drop Total;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put &amp;amp;&amp;amp;var6 &amp;amp;&amp;amp;var7 &amp;amp;&amp;amp;var8 &amp;amp;&amp;amp;var9;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2017 11:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358204#M84150</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-05-12T11:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358205#M84151</link>
      <description>&lt;P&gt;Thank you all for the support. I ran the following statement &amp;nbsp;and I got what I am looking for.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%put&lt;/SPAN&gt; &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var6 &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var7 &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var8 &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var9&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 11:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358205#M84151</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-12T11:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358207#M84153</link>
      <description>&lt;P&gt;Thank you very much. I got the output with the below statement.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token macrostatement"&gt;%put&lt;/SPAN&gt; &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var6 &amp;amp;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var7 &lt;SPAN class="token operator"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var8 &lt;SPAN class="token operator"&gt;&amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;var9&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 11:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358207#M84153</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2017-05-12T11:57:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358278#M84165</link>
      <description>&lt;P&gt;Why not just print the numbers from the dataset instead of the macro variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set tnstfd11;
  call symputx(trt,ns);
  put trt= ns= ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why are you putting the numbers into macro variables anyway? &amp;nbsp;If you need them as macro variables then your probably should not be putting them into LOCAL macro variables as those will disappear when the macro finishes.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2017 16:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358278#M84165</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-05-12T16:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Macro help</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358622#M84301</link>
      <description>&lt;P&gt;Please mark this thread as solved then.&lt;/P&gt;</description>
      <pubDate>Sun, 14 May 2017 22:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-help/m-p/358622#M84301</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-05-14T22:28:33Z</dc:date>
    </item>
  </channel>
</rss>

