<?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: do while  loop to create tables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533159#M6147</link>
    <description>&lt;P&gt;Why?&lt;/P&gt;</description>
    <pubDate>Wed, 06 Feb 2019 07:34:38 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2019-02-06T07:34:38Z</dc:date>
    <item>
      <title>do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/532997#M6119</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a set of tables in two libraries. I need to create these tables in a work library.&lt;/P&gt;&lt;P&gt;So basically let's assume I have the following:&lt;/P&gt;&lt;P&gt;lib1.table_a&lt;/P&gt;&lt;P&gt;lib1.table_b&amp;nbsp; and so on&lt;/P&gt;&lt;P&gt;lib2.table_a&lt;/P&gt;&lt;P&gt;lib2.table_b ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired Output:&lt;/P&gt;&lt;P&gt;Work.Lib1_table_a&lt;/P&gt;&lt;P&gt;Work.Lib1_table_b&amp;nbsp;&lt;/P&gt;&lt;P&gt;Work.Lib2_table_a&lt;/P&gt;&lt;P&gt;Work.Lib2_table_b&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what have i done so far is:&lt;/P&gt;&lt;P&gt;%let Lib = Lib1.;&lt;BR /&gt;%let table = table_a;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data &amp;amp;table;&lt;BR /&gt;set &amp;amp;Lib&amp;amp;table;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I need to do is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Macro should simply read the data from ANY DATASET in source library and then output the TARGET table which is an exact copy of the SOURCE table, but its name was passed using %let statement &lt;STRONG&gt;(which I think I've done)&lt;/STRONG&gt;&lt;/LI&gt;&lt;LI&gt;Macro that includes “do while” statement application. The program should produce output when %let statement is set to YES, otherwise it should output error message in the log.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am not fluent in the loop subject so plain language would be highly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/532997#M6119</guid>
      <dc:creator>aggers</dc:creator>
      <dc:date>2019-02-05T16:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533001#M6120</link>
      <description>&lt;P&gt;Do you want&amp;nbsp;&lt;STRONG&gt;all&lt;/STRONG&gt; data sets from the spcified libraries to be copied?&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533001#M6120</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-02-05T16:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533005#M6121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258185"&gt;@aggers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a set of tables in two libraries. I need to create these tables in a work library.&lt;/P&gt;
&lt;P&gt;So basically let's assume I have the following:&lt;/P&gt;
&lt;P&gt;lib1.table_a&lt;/P&gt;
&lt;P&gt;lib1.table_b&amp;nbsp; and so on&lt;/P&gt;
&lt;P&gt;lib2.table_a&lt;/P&gt;
&lt;P&gt;lib2.table_b ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired Output:&lt;/P&gt;
&lt;P&gt;Work.Lib1_table_a&lt;/P&gt;
&lt;P&gt;Work.Lib1_table_b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Work.Lib2_table_a&lt;/P&gt;
&lt;P&gt;Work.Lib2_table_b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what have i done so far is:&lt;/P&gt;
&lt;P&gt;%let Lib = Lib1.;&lt;BR /&gt;%let table = table_a;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data &amp;amp;table;&lt;BR /&gt;set &amp;amp;Lib&amp;amp;table;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I need to do is:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Macro should simply read the data from ANY DATASET in source library and then output the TARGET table which is an exact copy of the SOURCE table, but its name was passed using %let statement &lt;STRONG&gt;(which I think I've done)&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;Macro that includes “do while” statement application. The program should produce output when %let statement is set to YES, otherwise it should output error message in the log.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I am not fluent in the loop subject so plain language would be highly appreciated.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC COPY does this without macros, without loops and without DO WHILE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc copy in=lib1 out=work mtype=DATA;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:39:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533005#M6121</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-05T16:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533008#M6122</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*concatenate the two libnames to one*/
libname comb (lib1 lib2);
/*then copy the combined libname to work using proc datasets or proc copy suggested by Paigemiller*/
proc datasets library=comb;
   copy out=work;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Feb 2019 16:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533008#M6122</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-05T16:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533024#M6123</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258185"&gt;@aggers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Desired Output:&lt;/P&gt;
&lt;P&gt;Work.Lib1_table_a&lt;/P&gt;
&lt;P&gt;Work.Lib1_table_b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Work.Lib2_table_a&lt;/P&gt;
&lt;P&gt;Work.Lib2_table_b&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How about this, it's not exactly the same as above, but it ought to serve the same purpose, with a lot less work, no macros or loops. LIB1 gets copied into WORK, and LIB2 gets copied into WORK2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options dlcreatedir;
libname work2 "%sysfunc(getoption(WORK))/%sysfunc(uuidgen())" access=temp;

proc copy in=lib1 out=work mtype=DATA;
run;
proc copy in=lib2 out=work2 mtype=DATA;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Feb 2019 17:55:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533024#M6123</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-05T17:55:46Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533156#M6145</link>
      <description>&lt;P&gt;Yes, and I have dozens of tables. The exercise needs to include %let statement and "do while".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 07:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533156#M6145</guid>
      <dc:creator>aggers</dc:creator>
      <dc:date>2019-02-06T07:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533157#M6146</link>
      <description>Thank you for that, it works but I need to use %let statement and "do while".</description>
      <pubDate>Wed, 06 Feb 2019 07:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533157#M6146</guid>
      <dc:creator>aggers</dc:creator>
      <dc:date>2019-02-06T07:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533159#M6147</link>
      <description>&lt;P&gt;Why?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 07:34:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533159#M6147</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-02-06T07:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533180#M6153</link>
      <description>it's a part of an exercise I have to do. I know there are many ways of completing this, but I need to use %let and "do while" statements to complete my task.</description>
      <pubDate>Wed, 06 Feb 2019 10:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533180#M6153</guid>
      <dc:creator>aggers</dc:creator>
      <dc:date>2019-02-06T10:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533324#M6167</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258185"&gt;@aggers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;it's a part of an exercise I have to do. I know there are many ways of completing this, but I need to use %let and "do while" statements to complete my task.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Any WHILE or UNTIL loop requires 1) what to loop over, 2) an incrementing&amp;nbsp;value rule&amp;nbsp;and 3)&amp;nbsp;an explicit stopping rule. Which values are you looping over? It is not clear exactly clear what the "variable" or "values" would be: 1 and 2 above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also have not supplied any idea of the stopping rule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will also say, besides other comments about use the correct tool for a task such as Proc Copy or Datasets in this case, that macro While and Until loops are often much harder to manage, at least in my experience then iterated loops over a known list of values.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533324#M6167</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-02-06T16:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: do while  loop to create tables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533329#M6168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/258185"&gt;@aggers&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;it's a part of an exercise I have to do. I know there are many ways of completing this, but I need to use %let and "do while" statements to complete my task.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So its a homework assignment? Usually, we expect you to write the code as far as you can go, and then if it's not working, show us the code and the LOG and we can help you get beyond that point.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:30:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/do-while-loop-to-create-tables/m-p/533329#M6168</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-02-06T16:30:48Z</dc:date>
    </item>
  </channel>
</rss>

