<?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: Query to find min and max of multiple datasets from same library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556869#M155163</link>
    <description>&lt;P&gt;Untested code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select MemName
    into :datasetList separated by ' '
    from sashelp.vtable 
      where LibName = 'LIBNAME_ALL_UPCASE'
  ;
quit;

data have / view=have;
  set &amp;amp;datasetList.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use proc means to calculate the statistics.&lt;/P&gt;</description>
    <pubDate>Tue, 07 May 2019 16:57:10 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2019-05-07T16:57:10Z</dc:date>
    <item>
      <title>Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556846#M155151</link>
      <description>&lt;P&gt;I have multiple datasets with different names under the the same library. All the variables in those datasets are same. Now I want to query the Minimum And maximum value of particular variable of all those datasets in a step or two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone of you guide me here.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556846#M155151</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-05-07T16:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556857#M155155</link>
      <description>&lt;P&gt;Assuming the data sets are the same structure and can be stacked, you can create a view and summarize that.Or you can summarize each data set individually and extract that information from the summary data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have / view=have;
set data1-data10;
run;

proc means data=have min max;
var var1-var3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have multiple datasets with different names under the the same library. All the variables in those datasets are same. Now I want to query the Minimum And maximum value of particular variable of all those datasets in a step or two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone of you guide me here.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:43:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556857#M155155</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-07T16:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556862#M155157</link>
      <description>Datasets names are like employee, salary, address etc and it is not like&lt;BR /&gt;data1 to data2.&lt;BR /&gt;&lt;BR /&gt;I failed to mention this in my initial post.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 May 2019 16:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556862#M155157</guid>
      <dc:creator>Babloo</dc:creator>
      <dc:date>2019-05-07T16:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556863#M155158</link>
      <description>Please post sample data and expected output.</description>
      <pubDate>Tue, 07 May 2019 16:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556863#M155158</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-07T16:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556864#M155159</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Datasets names are like employee, salary, address etc and it is not like&lt;BR /&gt;data1 to data2.&lt;BR /&gt;&lt;BR /&gt;I failed to mention this in my initial post.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You said:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;gt;&lt;SPAN&gt;All the variables in those datasets are same&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that true regardless of names? If so that's fine, just list the names. If not, then you have a&amp;nbsp; much more complex problem.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556864#M155159</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-07T16:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556866#M155161</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Datasets names are like employee, salary, address etc and it is not like&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;data1 to data2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You replace the &lt;FONT face="courier new,courier"&gt;data1-data10&lt;/FONT&gt;&amp;nbsp;in the example code with the names of your actual data sets.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:51:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556866#M155161</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-05-07T16:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556869#M155163</link>
      <description>&lt;P&gt;Untested code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select MemName
    into :datasetList separated by ' '
    from sashelp.vtable 
      where LibName = 'LIBNAME_ALL_UPCASE'
  ;
quit;

data have / view=have;
  set &amp;amp;datasetList.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use proc means to calculate the statistics.&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 16:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556869#M155163</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-05-07T16:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556877#M155168</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/8409"&gt;@Babloo&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have multiple datasets with different names under the the same library. All the variables in those datasets are same. Now I want to query the Minimum And maximum value of particular variable of all those datasets in a step or two.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Appreciate if someone of you guide me here.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Another point to clarify, do you want the single minimum/ maximum across all of the data sets or for each dataset with an indicator of which set each max/ min is from?&lt;/P&gt;</description>
      <pubDate>Tue, 07 May 2019 17:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556877#M155168</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-07T17:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Query to find min and max of multiple datasets from same library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556880#M155171</link>
      <description>&lt;P&gt;Very interesting to see different approaches. I realize mine is probably less efficient than the others. I really like to use macros with CALL EXECUTE, so my strategy was to use dictionary tables (like another&amp;nbsp;user did) to obtain the list of tables that need to be summarized.&amp;nbsp;With this, I created a table of data set names that could be used with a CALL EXECUTE statement.&amp;nbsp;&amp;nbsp;This way, the macro with PROC MEANS can run on each data set. At the end, a DATA step concatenates all of the summary tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IMPORTANT: This code assumes that your TEST library ONLY has the tables you want to use to calculate summary statistics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname test '&amp;lt;PATH&amp;gt;';

data test.A;
  input x y;
  cards;
  1 2
  3 4
  5 6
;
run;

data test.b;
  input x y;
  cards;
  7 8
  9 10
  11 12
;
run;

proc sql;
   create table macros as
   select strip(memname) as table_name from dictionary.tables
   where libname = 'TEST';
quit;

%macro means(dsn);
proc means data=Test.&amp;amp;dsn;
   var x;
   output max=maximum min=minimum out=Test.Summary&amp;amp;DSN ;
run;
data Test.Summary&amp;amp;DSN;
   set Test.Summary&amp;amp;DSN;
   dataset = "&amp;amp;dsn";
%mend means;  

data _null_;
set macros;
  call execute('%means('||table_name||')');
  run;

data Test.Finished;
  set Test.Summary:;
  run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 May 2019 17:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Query-to-find-min-and-max-of-multiple-datasets-from-same-library/m-p/556880#M155171</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2019-05-07T17:06:54Z</dc:date>
    </item>
  </channel>
</rss>

