<?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: Conditionally assign a library? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671463#M201645</link>
    <description>&lt;P&gt;Can you show some code. If mac variables are mac1 , mac2, mac3 and mac4 and they have a boolean of YES or NO&amp;nbsp;you can do the following&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro assign_libname;
%if &amp;amp;mac1 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 1&amp;gt;);
run;
%end;
%if &amp;amp;mac1 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 1&amp;gt;);
run;
%end;
%if &amp;amp;mac2 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 2&amp;gt;);
run;
%end;
%if &amp;amp;mac3 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 3&amp;gt;);
run;
%end;
%if &amp;amp;mac4 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 4&amp;gt;);
run;
%end;
%mend assign_libname;
%assign_libname;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my guess is libname in open code is compile time statement and hence you see the behavior.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jul 2020 16:46:16 GMT</pubDate>
    <dc:creator>smantha</dc:creator>
    <dc:date>2020-07-22T16:46:16Z</dc:date>
    <item>
      <title>Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671455#M201643</link>
      <description>&lt;P&gt;Is there a way to conditionally assign a library?&amp;nbsp; I have an EG project (egp file) with a prompt, and I want the user to pick which of 4 databases they want to connect to.&amp;nbsp; If they pick 2, then I only want to invoke the libname statements for the 2 they selected.&amp;nbsp; I have 4 macro variables that indicate whether they want the library assigned or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is not working to put the libname statement in a select or an if-then-else because it gets invoked regardless.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 16:45:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671455#M201643</guid>
      <dc:creator>MrsC</dc:creator>
      <dc:date>2020-07-22T16:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671463#M201645</link>
      <description>&lt;P&gt;Can you show some code. If mac variables are mac1 , mac2, mac3 and mac4 and they have a boolean of YES or NO&amp;nbsp;you can do the following&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro assign_libname;
%if &amp;amp;mac1 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 1&amp;gt;);
run;
%end;
%if &amp;amp;mac1 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 1&amp;gt;);
run;
%end;
%if &amp;amp;mac2 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 2&amp;gt;);
run;
%end;
%if &amp;amp;mac3 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 3&amp;gt;);
run;
%end;
%if &amp;amp;mac4 = YES %then %do;
data _NULL_;
call execute(&amp;lt;libname statement 4&amp;gt;);
run;
%end;
%mend assign_libname;
%assign_libname;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;my guess is libname in open code is compile time statement and hence you see the behavior.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 16:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671463#M201645</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-22T16:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671466#M201648</link>
      <description>&lt;P&gt;Use the libname function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;

if "&amp;amp;mac1" = "Y" then libname(name, path);
if "&amp;amp;mac2" = "Y" then libname(......);
if "&amp;amp;mac3" = "Y" then libname(......);
if "&amp;amp;mac4" = "Y" then libname(......);

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265778"&gt;@MrsC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is there a way to conditionally assign a library?&amp;nbsp; I have an EG project (egp file) with a prompt, and I want the user to pick which of 4 databases they want to connect to.&amp;nbsp; If they pick 2, then I only want to invoke the libname statements for the 2 they selected.&amp;nbsp; I have 4 macro variables that indicate whether they want the library assigned or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is not working to put the libname statement in a select or an if-then-else because it gets invoked regardless.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 16:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671466#M201648</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-22T16:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671468#M201650</link>
      <description>&lt;P&gt;did not think of libname function.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 16:54:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671468#M201650</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-22T16:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671470#M201652</link>
      <description>I likely have the benefit of seeing this problem before &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 22 Jul 2020 16:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671470#M201652</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-07-22T16:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671496#M201662</link>
      <description>CALL EXECUTE! Of course! Thank you so much.</description>
      <pubDate>Wed, 22 Jul 2020 17:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671496#M201662</guid>
      <dc:creator>MrsC</dc:creator>
      <dc:date>2020-07-22T17:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally assign a library?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671531#M201673</link>
      <description>&lt;P&gt;I find&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp; Solution much elegant than what I provided.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jul 2020 18:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-assign-a-library/m-p/671531#M201673</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-07-22T18:33:31Z</dc:date>
    </item>
  </channel>
</rss>

