<?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: How to set most datasets in a library but except for a few datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841887#M332889</link>
    <description>Hi Patrick, thank you! This method works for me! It is great that it gives libname in the macro name so I can set dataset in any library.</description>
    <pubDate>Tue, 01 Nov 2022 14:34:30 GMT</pubDate>
    <dc:creator>Sally_Caffrey</dc:creator>
    <dc:date>2022-11-01T14:34:30Z</dc:date>
    <item>
      <title>How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841829#M332865</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have many datasets in a library with same name prefix like x_. I want to set most of them into one dataset, however except for a few datasets like x_11 and x_23.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code is :&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; set x_:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to exclude x_11 and x_23 from set statement ?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 11:11:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841829#M332865</guid>
      <dc:creator>Sally_Caffrey</dc:creator>
      <dc:date>2022-11-01T11:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841832#M332868</link>
      <description>&lt;P&gt;I can think of two ways, the first may not be the fastest since it reads all data sets and then discard records from the unwanted data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set x_: indsname=indsname;
    if indsname =:'WORK.X_11' or indsname=:'WORK.X_23' then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second way is to create a macro variable which lists all the data sets except the ones you don't want, then use the macro variable in the SET statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    select memname into :names separated by ' ' from dictionary.tables 
    where libname="WORK" and memname eqt 'X_' and memname net 'X_11' and memname net 'X_23';
quit;
data want;
    set &amp;amp;names;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 11:31:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841832#M332868</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-01T11:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841833#M332869</link>
      <description>&lt;P&gt;Below how that's often done.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  select cats(libname,'.',memname) into :memlist separated by ' '
  from dictionary.tables
  where 
    libname = 'WORK' and 
    memname not in ('X_11','X_23')
  ;
quit;

data want;
  set &amp;amp;memlist;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 11:31:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841833#M332869</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-11-01T11:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841835#M332870</link>
      <description>&lt;P&gt;If all your data sets are sequentially numbered something like this should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set x_1 - x_10  x_12-x_22 x_24-x_&amp;lt;whatever the last number may be&amp;gt;
   ;
run;&lt;/PRE&gt;
&lt;P&gt;One concern though, how sure are you that all variables with the same names are of the same type or have the same lengths?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/433517"&gt;@Sally_Caffrey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have many datasets in a library with same name prefix like x_. I want to set most of them into one dataset, however except for a few datasets like x_11 and x_23.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code is :&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; set x_:;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to exclude x_11 and x_23 from set statement ?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 12:09:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841835#M332870</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-11-01T12:09:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841885#M332887</link>
      <description>&lt;P&gt;Thanks a lot! Since I only have ~50 datasets to combine, so the speed is not a problem. I tried the first way and it works after a little change:&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;data want;
    set x_: indsname=indsname;
    if scan(indsname,1,'.') ='WORK' and scan(indsname,2,'.') in ('X_11' 'X_23') then delete;
run;&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841885#M332887</guid>
      <dc:creator>Sally_Caffrey</dc:creator>
      <dc:date>2022-11-01T14:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841886#M332888</link>
      <description>&lt;P&gt;May I ask why the change was needed? It seems like the code I wrote ought to work unchanged.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841886#M332888</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-01T14:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841887#M332889</link>
      <description>Hi Patrick, thank you! This method works for me! It is great that it gives libname in the macro name so I can set dataset in any library.</description>
      <pubDate>Tue, 01 Nov 2022 14:34:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841887#M332889</guid>
      <dc:creator>Sally_Caffrey</dc:creator>
      <dc:date>2022-11-01T14:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841888#M332890</link>
      <description>Hi Ballardw, the variables in all of datasets are created using one blank dataset with specific variable names, in wihch the variables format have been set up.&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841888#M332890</guid>
      <dc:creator>Sally_Caffrey</dc:creator>
      <dc:date>2022-11-01T14:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841889#M332891</link>
      <description>Sorry I write the code incorrecly just now. Your code is correct. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; May I ask why use =: ？The result does not change if remove ':'</description>
      <pubDate>Tue, 01 Nov 2022 14:48:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841889#M332891</guid>
      <dc:creator>Sally_Caffrey</dc:creator>
      <dc:date>2022-11-01T14:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to set most datasets in a library but except for a few datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841891#M332892</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/433517"&gt;@Sally_Caffrey&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry I write the code incorrecly just now. Your code is correct. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; May I ask why use =: ？The result does not change if remove ':'&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In your original problem statement, where you used&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set x_:;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it wasn't clear to me if the data set names were X_1 X_2 X_3 and so on, or could there also be X_1a X_2a X_3b. So the =: (equal-colon) was used to find all data set names that&amp;nbsp;&lt;EM&gt;begin with&amp;nbsp;&lt;/EM&gt;X_. That's what the =: does, it looks for strings that begin with whatever is in the quotes to the right of the =:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would appear that you don't have anything other than numbers after X_ and so the colon is not needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also realize now that if you have X_233, then this will not get selected as anything that begins with X_23 is not selected. So really, a more complete specification of the problem would have helped.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 14:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-set-most-datasets-in-a-library-but-except-for-a-few/m-p/841891#M332892</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-01T14:53:54Z</dc:date>
    </item>
  </channel>
</rss>

