<?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: Create a subset of all datasets in a library to a new library in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914732#M360458</link>
    <description>Do you want the data sets copied to a new library?  Or do you want a new dataset with all the results combined into one dataset in a new library?&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 06 Feb 2024 18:13:36 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2024-02-06T18:13:36Z</dc:date>
    <item>
      <title>Create a subset of all datasets in a library to a new library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914730#M360456</link>
      <description>&lt;P&gt;Hi Community,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a new SAS user and trying to figure out a way to create subsets of all the datasets in a library to a new library. All the datasets in the library have a variable "FolderName". All I need to to create a new library for all the rows that have&amp;nbsp;FolderName="NEW". I have around 50 datasets in the library. Is there a way to do this without specifying all the names in the library?.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset has 3 variables&amp;nbsp;Subject FolderName City&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 17:28:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914730#M360456</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2024-02-06T17:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset of all datasets in a library to a new library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914731#M360457</link>
      <description>&lt;P&gt;Better (much easier): when you want to use the datasets, use them from the current library, and use the WHERE statement to get just those rows where&amp;nbsp;&lt;SPAN&gt;FolderName="NEW". No need to create a whole new library.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=yourdatasetname;
    where foldername="NEW";
    table city;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No new library needed.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 19:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914731#M360457</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-02-06T19:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset of all datasets in a library to a new library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914732#M360458</link>
      <description>Do you want the data sets copied to a new library?  Or do you want a new dataset with all the results combined into one dataset in a new library?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Feb 2024 18:13:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914732#M360458</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-02-06T18:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a subset of all datasets in a library to a new library</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914745#M360467</link>
      <description>&lt;P&gt;Do all of the dataset have the variable FOLDERNAME?&lt;/P&gt;
&lt;P&gt;If so you just need the list of member names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname old 'current directory';
libname new 'new directory';
proc contents data=old._all_ noprint out=contents; run;
filename code temp;
data _null_;
  set contents;
  by memname;
  if first.memname;
  file code;
  put 'data new.' memname ';'
    / '  set old.' memname ';'
    / '  where foldername="NEW";'
    / 'run;'
  ;
run;
%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If not you need to specify what to do with the datasets that do not have the FOLDERNAME variable.&lt;/P&gt;
&lt;P&gt;If you want to skip them then just add a WHERE statement to the the data _null_ step above;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where upcase(name)='FOLDERNAME';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Feb 2024 19:17:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-subset-of-all-datasets-in-a-library-to-a-new-library/m-p/914745#M360467</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-06T19:17:19Z</dc:date>
    </item>
  </channel>
</rss>

