<?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 loop the code based on the tab name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/loop-the-code-based-on-the-tab-name/m-p/492866#M129615</link>
    <description>&lt;P&gt;i have an excel with change in no. of tabs every month.&amp;nbsp; i have written a code for each tab as below. I want to loop the code for each tab and create a new table.&lt;/P&gt;&lt;P&gt;if i have 3 tabs i am importing 3 times with sheet name change &amp;amp; out file name change. ( can we loop this ?????)&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT=file.orders&lt;BR /&gt;DATAFILE="&amp;amp;filepath"&lt;BR /&gt;DBMS=XLSX;&lt;BR /&gt;Sheet="orders"&amp;nbsp; /* changing every month the name*/&amp;nbsp;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, i have 3 times this code based on the data and create new output table. ( i want to loop import and code and create a table for each of it)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;alter table file.customer&lt;BR /&gt;add Order_ID char(20) format = $20.;&lt;BR /&gt;update &lt;SPAN&gt;file.customer&lt;/SPAN&gt; as A&lt;BR /&gt;set Order_ID = (select b.Cust_ID from&amp;nbsp;file.Orders as b&lt;BR /&gt;where A.Cust_ID=b.Cust_ID);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data Patch.Order_final;&lt;BR /&gt;length Order_1 $ 4;&lt;BR /&gt;set &lt;SPAN&gt;file.customer&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;if (Order_ID=Cust_ID) then&lt;BR /&gt;order_1="Yes";&lt;BR /&gt;else&lt;BR /&gt;order_1="No";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me how can i reduce manual updates and loop the code based on number of tabs.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Sep 2018 02:32:47 GMT</pubDate>
    <dc:creator>radha009</dc:creator>
    <dc:date>2018-09-06T02:32:47Z</dc:date>
    <item>
      <title>loop the code based on the tab name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-the-code-based-on-the-tab-name/m-p/492866#M129615</link>
      <description>&lt;P&gt;i have an excel with change in no. of tabs every month.&amp;nbsp; i have written a code for each tab as below. I want to loop the code for each tab and create a new table.&lt;/P&gt;&lt;P&gt;if i have 3 tabs i am importing 3 times with sheet name change &amp;amp; out file name change. ( can we loop this ?????)&lt;/P&gt;&lt;P&gt;PROC IMPORT OUT=file.orders&lt;BR /&gt;DATAFILE="&amp;amp;filepath"&lt;BR /&gt;DBMS=XLSX;&lt;BR /&gt;Sheet="orders"&amp;nbsp; /* changing every month the name*/&amp;nbsp;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, i have 3 times this code based on the data and create new output table. ( i want to loop import and code and create a table for each of it)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;alter table file.customer&lt;BR /&gt;add Order_ID char(20) format = $20.;&lt;BR /&gt;update &lt;SPAN&gt;file.customer&lt;/SPAN&gt; as A&lt;BR /&gt;set Order_ID = (select b.Cust_ID from&amp;nbsp;file.Orders as b&lt;BR /&gt;where A.Cust_ID=b.Cust_ID);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;data Patch.Order_final;&lt;BR /&gt;length Order_1 $ 4;&lt;BR /&gt;set &lt;SPAN&gt;file.customer&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;if (Order_ID=Cust_ID) then&lt;BR /&gt;order_1="Yes";&lt;BR /&gt;else&lt;BR /&gt;order_1="No";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please help me how can i reduce manual updates and loop the code based on number of tabs.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 02:32:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-the-code-based-on-the-tab-name/m-p/492866#M129615</guid>
      <dc:creator>radha009</dc:creator>
      <dc:date>2018-09-06T02:32:47Z</dc:date>
    </item>
    <item>
      <title>Re: loop the code based on the tab name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/loop-the-code-based-on-the-tab-name/m-p/492868#M129617</link>
      <description>&lt;P&gt;Wrap it in macros and call as needed. It also depends on how much of the code is repeatable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on converting a working program into a macro. You should always start with a full working program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In addition, I highly recommend the SAS Macro Appendix Library, where you'll find several examples of looping macro variables and calling it multiple times.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need further help, please post specific questions with code and an explanation of what's going wrong.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/192083"&gt;@radha009&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i have an excel with change in no. of tabs every month.&amp;nbsp; i have written a code for each tab as below. I want to loop the code for each tab and create a new table.&lt;/P&gt;
&lt;P&gt;if i have 3 tabs i am importing 3 times with sheet name change &amp;amp; out file name change. ( can we loop this ?????)&lt;/P&gt;
&lt;P&gt;PROC IMPORT OUT=file.orders&lt;BR /&gt;DATAFILE="&amp;amp;filepath"&lt;BR /&gt;DBMS=XLSX;&lt;BR /&gt;Sheet="orders"&amp;nbsp; /* changing every month the name*/&amp;nbsp;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, i have 3 times this code based on the data and create new output table. ( i want to loop import and code and create a table for each of it)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;alter table file.customer&lt;BR /&gt;add Order_ID char(20) format = $20.;&lt;BR /&gt;update &lt;SPAN&gt;file.customer&lt;/SPAN&gt; as A&lt;BR /&gt;set Order_ID = (select b.Cust_ID from&amp;nbsp;file.Orders as b&lt;BR /&gt;where A.Cust_ID=b.Cust_ID);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data Patch.Order_final;&lt;BR /&gt;length Order_1 $ 4;&lt;BR /&gt;set &lt;SPAN&gt;file.customer&lt;/SPAN&gt;;&lt;/P&gt;
&lt;P&gt;if (Order_ID=Cust_ID) then&lt;BR /&gt;order_1="Yes";&lt;BR /&gt;else&lt;BR /&gt;order_1="No";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please help me how can i reduce manual updates and loop the code based on number of tabs.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 02:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/loop-the-code-based-on-the-tab-name/m-p/492868#M129617</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-06T02:46:50Z</dc:date>
    </item>
  </channel>
</rss>

