<?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: How to change a loop in an existing code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798239#M313815</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I wrote the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);
...

%getTables();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the loop not to try to read from the SAPBW library two tables.&lt;BR /&gt;Table names:&amp;nbsp;&lt;SPAN&gt;_BI0_TRELOCAT +&amp;nbsp;_BI0_TLVANOFT.&lt;/SPAN&gt;&lt;BR /&gt;What change should be made to the code?&lt;/P&gt;
&lt;P&gt;Thank's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You've set the macro at the top to read from the SAPBW library. If you want to change that library you can try to change the macro call.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getTables(saplib=newLibraryHERE, saslib=SAP_TEXT);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I wrote the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);

options validmemname=extend validvarname=any;
 
data texttbls;
   set sashelp.vtable;
   where libname = "&amp;amp;saplib" and (memname =: "/BI0/T" or memname =: "/BIC/T");
run;

 
data _null_;
   set texttbls;
   call symputx('texttbls',_n_);
   call symputx(catt('saptexttbl',_n_),memname);
   call symputx(catt('sastexttbl',_n_),translate(memname,"_","/"));
run;


%do i = 1 %to &amp;amp;texttbls;
   data &amp;amp;saslib.."&amp;amp;&amp;amp;sastexttbl&amp;amp;i"n;
      set &amp;amp;saplib.."&amp;amp;&amp;amp;saptexttbl&amp;amp;i"n;
   run;

%end;

%mend;

%getTables();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the loop not to try to read from the SAPBW library two tables.&lt;BR /&gt;Table names:&amp;nbsp;&lt;SPAN&gt;_BI0_TRELOCAT +&amp;nbsp;_BI0_TLVANOFT.&lt;/SPAN&gt;&lt;BR /&gt;What change should be made to the code?&lt;/P&gt;
&lt;P&gt;Thank's.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Feb 2022 20:27:35 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2022-02-23T20:27:35Z</dc:date>
    <item>
      <title>How to change a loop in an existing code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798215#M313806</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I wrote the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);

options validmemname=extend validvarname=any;
 
data texttbls;
   set sashelp.vtable;
   where libname = "&amp;amp;saplib" and (memname =: "/BI0/T" or memname =: "/BIC/T");
run;

 
data _null_;
   set texttbls;
   call symputx('texttbls',_n_);
   call symputx(catt('saptexttbl',_n_),memname);
   call symputx(catt('sastexttbl',_n_),translate(memname,"_","/"));
run;


%do i = 1 %to &amp;amp;texttbls;
   data &amp;amp;saslib.."&amp;amp;&amp;amp;sastexttbl&amp;amp;i"n;
      set &amp;amp;saplib.."&amp;amp;&amp;amp;saptexttbl&amp;amp;i"n;
   run;

%end;

%mend;

%getTables();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the loop not to try to read from the SAPBW library two tables.&lt;BR /&gt;Table names:&amp;nbsp;&lt;SPAN&gt;_BI0_TRELOCAT +&amp;nbsp;_BI0_TLVANOFT.&lt;/SPAN&gt;&lt;BR /&gt;What change should be made to the code?&lt;/P&gt;
&lt;P&gt;Thank's.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 19:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798215#M313806</guid>
      <dc:creator>shlomiohana</dc:creator>
      <dc:date>2022-02-23T19:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a loop in an existing code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798217#M313808</link>
      <description>&lt;P&gt;So is the actual requirement that you don't want to run the data step when the name is not changing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so add a WHERE statement to the data step or augment the WHERE condition in the SQL query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set texttbls;
   where memname ne translate(memname,"_","/");
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps just&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set texttbls;
   where indexc(memname,'/');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Feb 2022 19:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798217#M313808</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-23T19:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a loop in an existing code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798226#M313812</link>
      <description>&lt;P&gt;Since you have the names of the tables in a data set I would consider using Call Execute instead of creating macro variables.&lt;/P&gt;
&lt;P&gt;Then you could test the value of the Memname variable not do the call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dummy code;&lt;/P&gt;
&lt;PRE&gt;data _null_;
   set texttbls;
   if memname not in ("_BIO_TRELOCAT" "_BIO_TLVANOFT") then
       call execute ("build that data step code here");
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 19:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798226#M313812</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-23T19:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to change a loop in an existing code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798239#M313815</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I wrote the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);
...

%getTables();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the loop not to try to read from the SAPBW library two tables.&lt;BR /&gt;Table names:&amp;nbsp;&lt;SPAN&gt;_BI0_TRELOCAT +&amp;nbsp;_BI0_TLVANOFT.&lt;/SPAN&gt;&lt;BR /&gt;What change should be made to the code?&lt;/P&gt;
&lt;P&gt;Thank's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You've set the macro at the top to read from the SAPBW library. If you want to change that library you can try to change the macro call.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%getTables(saplib=newLibraryHERE, saslib=SAP_TEXT);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/288727"&gt;@shlomiohana&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I wrote the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);

options validmemname=extend validvarname=any;
 
data texttbls;
   set sashelp.vtable;
   where libname = "&amp;amp;saplib" and (memname =: "/BI0/T" or memname =: "/BIC/T");
run;

 
data _null_;
   set texttbls;
   call symputx('texttbls',_n_);
   call symputx(catt('saptexttbl',_n_),memname);
   call symputx(catt('sastexttbl',_n_),translate(memname,"_","/"));
run;


%do i = 1 %to &amp;amp;texttbls;
   data &amp;amp;saslib.."&amp;amp;&amp;amp;sastexttbl&amp;amp;i"n;
      set &amp;amp;saplib.."&amp;amp;&amp;amp;saptexttbl&amp;amp;i"n;
   run;

%end;

%mend;

%getTables();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want the loop not to try to read from the SAPBW library two tables.&lt;BR /&gt;Table names:&amp;nbsp;&lt;SPAN&gt;_BI0_TRELOCAT +&amp;nbsp;_BI0_TLVANOFT.&lt;/SPAN&gt;&lt;BR /&gt;What change should be made to the code?&lt;/P&gt;
&lt;P&gt;Thank's.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 20:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-change-a-loop-in-an-existing-code/m-p/798239#M313815</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-02-23T20:27:35Z</dc:date>
    </item>
  </channel>
</rss>

