<?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 macro looping on diffrent tables in diffrent libs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448600#M112857</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;Hi All,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;I have &lt;STRONG&gt;100&lt;/STRONG&gt;+ sas datasets in each library that contain data on consumers individual characteristics such as id, gender, age,etc.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;How can I write a multiple loop to go through each of the datasets in each library, do some manipulations and save the estimated values to a same file.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　my code;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test.table;
	set test.table
	%testall(test.table);

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　I want to apply %&lt;STRONG&gt;&lt;I&gt;testall macro &amp;nbsp;for&amp;nbsp; all the tables in all libraries. &lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
    <pubDate>Mon, 26 Mar 2018 11:50:51 GMT</pubDate>
    <dc:creator>sathya66</dc:creator>
    <dc:date>2018-03-26T11:50:51Z</dc:date>
    <item>
      <title>macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448600#M112857</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;Hi All,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;I have &lt;STRONG&gt;100&lt;/STRONG&gt;+ sas datasets in each library that contain data on consumers individual characteristics such as id, gender, age,etc.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="4"&gt;How can I write a multiple loop to go through each of the datasets in each library, do some manipulations and save the estimated values to a same file.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　my code;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test.table;
	set test.table
	%testall(test.table);

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;　I want to apply %&lt;STRONG&gt;&lt;I&gt;testall macro &amp;nbsp;for&amp;nbsp; all the tables in all libraries. &lt;/I&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 11:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448600#M112857</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-26T11:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448606#M112858</link>
      <description>&lt;P&gt;You need to create a macro variable that has the name of the 100 tables (probably using PROC SQL), let's say it is &amp;amp;list_of_table_names&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro do_all(table_names=);
%do i=1 %to %sysfunc(countw(&amp;amp;table_names));
    %let this_table_name=%scan(&amp;amp;table_names,&amp;amp;i,%str( ));
    data a;
         set &amp;amp;this_table_name;
         ... your calculations go here ...
     run;
     proc append base=all new=a;
     run;
%end;
%mend;
%do_all(table_names=&amp;amp;list_of_table_names)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 12:21:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448606#M112858</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-26T12:21:33Z</dc:date>
    </item>
    <item>
      <title>Re: macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448610#M112859</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro testall(dsn);
 %put Table= &amp;amp;dsn ;
%mend;
data _null_;
 set sashelp.vmember(where=(memtype='DATA'));
 call execute(cats('%testall(',libname,'.',memname,')'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Mar 2018 12:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448610#M112859</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-03-26T12:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448611#M112860</link>
      <description>&lt;P&gt;Thanks&amp;nbsp; Miller,&lt;/P&gt;&lt;P&gt;I have different approach , please can you review .&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro loopOverDatasets(inLibref);  
    ods output Members=Members;
 proc datasets library=&amp;amp;inLibref memtype=data;
 run;
 quit;
    %local datasetCount iter inLibref inMember;
    /*get number of datasets*/
    proc sql noprint;
        select count(*)
         into :datasetCount
        from WORK.Members;
    quit;

    /*initiate loop*/
    %let iter=1;
    %do %while (&amp;amp;iter.&amp;lt;= &amp;amp;datasetCount.);
        
        data _NULL_;
            set WORK.Members (firstobs=&amp;amp;iter. obs=&amp;amp;iter.); *only read 1 record;
         
            call symput("inMember",strip(Name));
           
        run;

        /* applying my logic to the dataset*/
        data &amp;amp;inLibref..&amp;amp;inMember.; 
            set &amp;amp;inLibref..&amp;amp;inMember.;
          %testall(&amp;amp;inLibref..&amp;amp;inMember.);
        run;



        /*increment the iterator of the loop*/
        %let iter=%eval(&amp;amp;iter.+1);
    %end;
%mend;

/*call the macro*/
%loopOverDatasets(work);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 12:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448611#M112860</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-26T12:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448614#M112861</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Thanks&amp;nbsp; Miller,&lt;/P&gt;
&lt;P&gt;I have different approach , please can you review .&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why don't you execute the code and see if it works?&lt;/P&gt;</description>
      <pubDate>Mon, 26 Mar 2018 12:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448614#M112861</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-03-26T12:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: macro looping on diffrent tables in diffrent libs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448617#M112862</link>
      <description>yes,It is working and I accepted it.&lt;BR /&gt;Thanks,&lt;BR /&gt;SS</description>
      <pubDate>Mon, 26 Mar 2018 12:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-looping-on-diffrent-tables-in-diffrent-libs/m-p/448617#M112862</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-26T12:48:45Z</dc:date>
    </item>
  </channel>
</rss>

