<?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: sas setting table in a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659951#M197588</link>
    <description>&lt;P&gt;alternatively you can try the below code with do loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
set test nobs=obs;
call symputx("test"||strip(put(_n_,best.)),cats('test',date_loop));
call symputx("obs",strip(obs));
run;

%put &amp;amp;test1 &amp;amp;test2 &amp;amp;obs;

%macro test;
data want;
set
%do i = 1 %to &amp;amp;obs;
 &amp;amp;&amp;amp;test&amp;amp;i
%end;;
run;
%mend;

%test;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 16 Jun 2020 09:57:36 GMT</pubDate>
    <dc:creator>Jagadishkatam</dc:creator>
    <dc:date>2020-06-16T09:57:36Z</dc:date>
    <item>
      <title>sas setting table in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659799#M197583</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data test; 
   input date_loop $;
   datalines;                      
20200601
20200602
20200603
20200604
20200605
20200606
20200607
20200608
20200609
20200610
20200611
;
run;

/*
I have multiple tables : work.table20200601, work.table20200602, work.table20200603 etc. 
I' d like to iterate from this test table in a loop. Something like this:

data set_tables;
set 
	work.test20200601
	work.test20200602
	work.test20200603
	work.test20200604
	work.test20200605
	work.test20200606
	work.test20200607
	work.test20200608
	work.test20200609
	work.test20200610
	work.test20200611
;
run;
*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jun 2020 09:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659799#M197583</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2020-06-16T09:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: sas setting table in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659873#M197585</link>
      <description>&lt;P&gt;The first method (and the easiest and quickest) is to use wildcards:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data set_tables;
set 
  work.test202006:
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The second is the creation of a macro variable (if the wildcard would otherwise pick up unwanted datasets):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select 'WORK.' !! date_loop into :datasets separated by " "
from test;
quit;

data set_tables;
set &amp;amp;datasets.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 09:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659873#M197585</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-16T09:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: sas setting table in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659886#M197586</link>
      <description>&lt;P&gt;If your task is to read all data sets with the prefix work.test202006, then simply use the colon operator like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set work.test202006: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise, you can use Call Execute logic like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test; 
   input date_loop $;
   datalines;                      
20200601
20200602
20200603
20200604
20200605
20200606
20200607
20200608
20200609
20200610
20200611
;
run;

data _null_;
   set test;
   call execute ("data set_tables; set ");
   call execute (cat("work.test", date_loop));
   call execute ("; run;");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 09:40:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659886#M197586</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-06-16T09:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: sas setting table in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659887#M197587</link>
      <description>Thanks for your help!</description>
      <pubDate>Tue, 16 Jun 2020 09:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659887#M197587</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2020-06-16T09:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: sas setting table in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659951#M197588</link>
      <description>&lt;P&gt;alternatively you can try the below code with do loop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
set test nobs=obs;
call symputx("test"||strip(put(_n_,best.)),cats('test',date_loop));
call symputx("obs",strip(obs));
run;

%put &amp;amp;test1 &amp;amp;test2 &amp;amp;obs;

%macro test;
data want;
set
%do i = 1 %to &amp;amp;obs;
 &amp;amp;&amp;amp;test&amp;amp;i
%end;;
run;
%mend;

%test;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 09:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-setting-table-in-a-loop/m-p/659951#M197588</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2020-06-16T09:57:36Z</dc:date>
    </item>
  </channel>
</rss>

