<?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 Conditional usage of macros in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-usage-of-macros/m-p/5164#M2089</link>
    <description>I am newbie to SAS.&lt;BR /&gt;
Basically, I have written a few macros in SAS which I would like to activate when different conditons are met. &lt;BR /&gt;
For example ,I have a do loop and I would like diff macros to be called each time the do loop is incremented.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
(Toggle Plain Text) &lt;BR /&gt;
Data _NULL_&lt;BR /&gt;
&lt;BR /&gt;
Do i=0 to 10&lt;BR /&gt;
&lt;BR /&gt;
Select (i)&lt;BR /&gt;
&lt;BR /&gt;
When (0)%Macro1(var1);&lt;BR /&gt;
when(2) % macro2(var2);&lt;BR /&gt;
....&lt;BR /&gt;
otherwise&lt;BR /&gt;
end&lt;BR /&gt;
end&lt;BR /&gt;
Data _NULL_&lt;BR /&gt;
&lt;BR /&gt;
Do i=0 to 10&lt;BR /&gt;
&lt;BR /&gt;
Select (i)&lt;BR /&gt;
&lt;BR /&gt;
When (0)%Macro1(var1);&lt;BR /&gt;
when(2) % macro2(var2);&lt;BR /&gt;
....&lt;BR /&gt;
otherwise&lt;BR /&gt;
end&lt;BR /&gt;
end&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
However, I found that I cannot do that i.e. select different macros when different conditions are met. Anybody can suggest how I could achieve the same functionality? &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Also, is it possible to concatenate 2 macro strings.&lt;BR /&gt;
&lt;BR /&gt;
i.e. % Let macro1=ABC;&lt;BR /&gt;
%Let macro2=DEF;&lt;BR /&gt;
&lt;BR /&gt;
I would like to have &lt;BR /&gt;
%Let macro 3= ABCDEF; (but using macro1 and 2 since the values may change.)&lt;BR /&gt;
&lt;BR /&gt;
How can I do this??&lt;BR /&gt;
Thanks. &lt;BR /&gt;
&lt;BR /&gt;
(P.S if possible, do explain using code fragments as i am really very new to SAS and may not be aware of some of the "basic"rules of the language)</description>
    <pubDate>Mon, 22 Oct 2007 22:33:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2007-10-22T22:33:23Z</dc:date>
    <item>
      <title>Conditional usage of macros</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-usage-of-macros/m-p/5164#M2089</link>
      <description>I am newbie to SAS.&lt;BR /&gt;
Basically, I have written a few macros in SAS which I would like to activate when different conditons are met. &lt;BR /&gt;
For example ,I have a do loop and I would like diff macros to be called each time the do loop is incremented.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
(Toggle Plain Text) &lt;BR /&gt;
Data _NULL_&lt;BR /&gt;
&lt;BR /&gt;
Do i=0 to 10&lt;BR /&gt;
&lt;BR /&gt;
Select (i)&lt;BR /&gt;
&lt;BR /&gt;
When (0)%Macro1(var1);&lt;BR /&gt;
when(2) % macro2(var2);&lt;BR /&gt;
....&lt;BR /&gt;
otherwise&lt;BR /&gt;
end&lt;BR /&gt;
end&lt;BR /&gt;
Data _NULL_&lt;BR /&gt;
&lt;BR /&gt;
Do i=0 to 10&lt;BR /&gt;
&lt;BR /&gt;
Select (i)&lt;BR /&gt;
&lt;BR /&gt;
When (0)%Macro1(var1);&lt;BR /&gt;
when(2) % macro2(var2);&lt;BR /&gt;
....&lt;BR /&gt;
otherwise&lt;BR /&gt;
end&lt;BR /&gt;
end&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
However, I found that I cannot do that i.e. select different macros when different conditions are met. Anybody can suggest how I could achieve the same functionality? &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Also, is it possible to concatenate 2 macro strings.&lt;BR /&gt;
&lt;BR /&gt;
i.e. % Let macro1=ABC;&lt;BR /&gt;
%Let macro2=DEF;&lt;BR /&gt;
&lt;BR /&gt;
I would like to have &lt;BR /&gt;
%Let macro 3= ABCDEF; (but using macro1 and 2 since the values may change.)&lt;BR /&gt;
&lt;BR /&gt;
How can I do this??&lt;BR /&gt;
Thanks. &lt;BR /&gt;
&lt;BR /&gt;
(P.S if possible, do explain using code fragments as i am really very new to SAS and may not be aware of some of the "basic"rules of the language)</description>
      <pubDate>Mon, 22 Oct 2007 22:33:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-usage-of-macros/m-p/5164#M2089</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2007-10-22T22:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional usage of macros</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-usage-of-macros/m-p/5165#M2090</link>
      <description>Hi:&lt;BR /&gt;
  This question isn't about ODS or Base Reporting Procedures (PRINT, REPORT and TABULATE).&lt;BR /&gt;
 &lt;BR /&gt;
  There is no better documentation on Macro processing than the Macro reference in the documentation, the SUGI and SGF papers that have been written and the books by users on the topic of macro.&lt;BR /&gt;
&lt;BR /&gt;
  This forum posting, in particular, answers your second question about concatenating macro variables together:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=7694Ḏ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=7694Ḏ&lt;/A&gt;&lt;BR /&gt;
 &lt;BR /&gt;
  Your first question (about executing code conditionally using macro processing), besides being off-topic is WAY too big a topic to cover here in the forum.&lt;BR /&gt;
&lt;BR /&gt;
  Here are some links to other forums postings that you may find useful:&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=7089᮱" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=7089᮱&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=6402ᤂ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=6402ᤂ&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=5697ᙁ" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=5697ᙁ&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  This SUGI paper is particularly helpful:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi28/056-28.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi28/056-28.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
  For more help, you might consider contacting SAS Tech Support.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Mon, 22 Oct 2007 23:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Conditional-usage-of-macros/m-p/5165#M2090</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2007-10-22T23:22:11Z</dc:date>
    </item>
  </channel>
</rss>

