<?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 Combine hundreds of *.sas7bdat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51453#M10790</link>
    <description>Hi, I wanna combine hundreds of *.sas7bdat in one folder on Windows Platform. The names of datasets have no rule. How can I do put them together using data steps? &lt;BR /&gt;
Thank you for your time.

Message was edited by: Jun</description>
    <pubDate>Fri, 03 Oct 2008 03:14:00 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-10-03T03:14:00Z</dc:date>
    <item>
      <title>Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51453#M10790</link>
      <description>Hi, I wanna combine hundreds of *.sas7bdat in one folder on Windows Platform. The names of datasets have no rule. How can I do put them together using data steps? &lt;BR /&gt;
Thank you for your time.

Message was edited by: Jun</description>
      <pubDate>Fri, 03 Oct 2008 03:14:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51453#M10790</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T03:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51454#M10791</link>
      <description>What do you mean by putting then together?&lt;BR /&gt;
Have they the same table structure (column names/types)?&lt;BR /&gt;
&lt;BR /&gt;
You are probably looking into use DICTIONARY.TABLES from proc sql. There are several posts in the forums on this topic, as well as good documentation on support.sas.com.&lt;BR /&gt;
&lt;BR /&gt;
Good luck!&lt;BR /&gt;
&lt;BR /&gt;
Linus</description>
      <pubDate>Fri, 03 Oct 2008 07:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51454#M10791</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-10-03T07:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51455#M10792</link>
      <description>Thank you for your reply, Linus.&lt;BR /&gt;
The hundreds of datasets(*.sas7bdat) have same structure and are placed in same folder.&lt;BR /&gt;
Could you give me some code to merge them vertically?&lt;BR /&gt;
Data step is preferred, and PROC SQL is OK too.&lt;BR /&gt;
&lt;BR /&gt;
Thank you.</description>
      <pubDate>Fri, 03 Oct 2008 19:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51455#M10792</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T19:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51456#M10793</link>
      <description>Hi:&lt;BR /&gt;
  To concatenate tables together (or, in your terms, to join them vertically (as opposed to merging them), you could use either PROC APPEND or a SET statement in a DATA step. &lt;BR /&gt;
  So, if you had these two tables (for example) and they both had the same variables NAME and AGE, then you could contenate them together:&lt;BR /&gt;
[pre]&lt;BR /&gt;
TABLE1   &lt;BR /&gt;
NAME  AGE                                  &lt;BR /&gt;
Alan  15&lt;BR /&gt;
Bob   14&lt;BR /&gt;
Carla 15&lt;BR /&gt;
********************&lt;BR /&gt;
                              &lt;BR /&gt;
TABLE2&lt;BR /&gt;
NAME  AGE&lt;BR /&gt;
Dave  17&lt;BR /&gt;
Edna  16&lt;BR /&gt;
Fiona 14&lt;BR /&gt;
********************&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                           &lt;BR /&gt;
...with this program&lt;BR /&gt;
[pre]&lt;BR /&gt;
data newtable;&lt;BR /&gt;
  set table1 &lt;BR /&gt;
      table2;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                      &lt;BR /&gt;
would result in NEWTABLE containing:&lt;BR /&gt;
[pre]&lt;BR /&gt;
NEWTABLE  &lt;BR /&gt;
NAME  AGE                                  &lt;BR /&gt;
Alan  15&lt;BR /&gt;
Bob   14&lt;BR /&gt;
Carla 15&lt;BR /&gt;
Dave  17&lt;BR /&gt;
Edna  16&lt;BR /&gt;
Fiona 14&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
You could also use PROC APPEND, or PROC SQL.&lt;BR /&gt;
 &lt;BR /&gt;
If you want the list of DATASET names for the SET to be populated dynamically, then you would have to follow Linus' suggestion and investigate the use of DICTIONARY.TABLES and some simple SAS Macro processing (the use of INTO within an SQL query) to give you the names of the tables that you want to concatenate together.&lt;BR /&gt;
&lt;BR /&gt;
These papers may help you get started on finding out some uses for DICTIONARY.TABLES:&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi30/070-30.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi30/070-30.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www2.sas.com/proceedings/sugi29/237-29.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/sugi29/237-29.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf" target="_blank"&gt;http://www.lexjansen.com/pharmasug/2006/tutorials/tu03.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.lexjansen.com/pharmasug/2005/posters/po31.pdf" target="_blank"&gt;http://www.lexjansen.com/pharmasug/2005/posters/po31.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://www.sugme.org/sugme_dictionary.pdf" target="_blank"&gt;http://www.sugme.org/sugme_dictionary.pdf&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
If you know about SAS Macro processing, then the program below should be fairly simple to follow. If you don't know about SAS Macro processing, then I suggest that you investigate and learn about the SAS Macro facility before implementing a production solution. &lt;BR /&gt;
&lt;BR /&gt;
The program below creates 3 datasets (copies of SASHELP.CLASS) in the WORK library and then the PROC SQL step creates a macro variable containing the names of the files just created based on the LIBNAME='WORK' and MEMNAME contains 'CLASS' (your criteria may be different for choosing). Finally, the macro variable created in the PROC SQL step is used in a SET statement.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
** 1) Make Some Data (you do not need this step);&lt;BR /&gt;
data class_one;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  fileind = 1;&lt;BR /&gt;
run;&lt;BR /&gt;
                                         &lt;BR /&gt;
data class_two;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  fileind = 2;&lt;BR /&gt;
run;&lt;BR /&gt;
                                                    &lt;BR /&gt;
data class_three;&lt;BR /&gt;
  set sashelp.class;&lt;BR /&gt;
  fileind = 3;&lt;BR /&gt;
run;&lt;BR /&gt;
                            &lt;BR /&gt;
** 2) Discover names of all "CLASS" files in Work;&lt;BR /&gt;
**    LIBNAME AND MEMNAME values should be uppercased.;&lt;BR /&gt;
**    Your selection criteria (WHERE clause) may be different.;&lt;BR /&gt;
proc sql;&lt;BR /&gt;
  select catt(libname,'.',memname) &lt;BR /&gt;
         into :alldata separated by ' ' &lt;BR /&gt;
  from dictionary.tables&lt;BR /&gt;
  where libname = 'WORK' and&lt;BR /&gt;
        memname contains 'CLASS';&lt;BR /&gt;
quit;&lt;BR /&gt;
                                       &lt;BR /&gt;
%put The names of the files to concatenate are: &amp;amp;alldata;&lt;BR /&gt;
                                        &lt;BR /&gt;
** 3) Use the macro variable created above in a SET statement ;&lt;BR /&gt;
**    and verify that the data was created correctly;&lt;BR /&gt;
data vertical;&lt;BR /&gt;
  set &amp;amp;alldata;&lt;BR /&gt;
run;&lt;BR /&gt;
                                      &lt;BR /&gt;
proc freq data=vertical;&lt;BR /&gt;
  title 'After Macro method';&lt;BR /&gt;
  tables fileind;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Fri, 03 Oct 2008 20:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51456#M10793</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-10-03T20:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51457#M10794</link>
      <description>Got you! Thank you for your help.&lt;BR /&gt;
&lt;BR /&gt;
I learned a lot from you all.</description>
      <pubDate>Fri, 03 Oct 2008 23:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51457#M10794</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-10-03T23:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combine hundreds of *.sas7bdat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51458#M10795</link>
      <description>Just one more thing: Why duplicate data if there are views? &lt;BR /&gt;
And if there are more SAS tables in the future instead of processing everything "physically" you can just rebuild the view.&lt;BR /&gt;
HTH&lt;BR /&gt;
Patrick&lt;BR /&gt;
&lt;BR /&gt;
/*libname MyLib 'path to your directory';*/&lt;BR /&gt;
libname MyLib (sasuser);&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
  select catx('.',libname,memname) into :TblList separated by ' '&lt;BR /&gt;
    from dictionary.members&lt;BR /&gt;
      where libname='MYLIB' and memtype='DATA'&lt;BR /&gt;
  ;&lt;BR /&gt;
  %put The following tables are in the library:;&lt;BR /&gt;
  %put &amp;amp;TblList;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
data work.MyView / view=work.MyView;&lt;BR /&gt;
  set &amp;amp;TblList;&lt;BR /&gt;
run;</description>
      <pubDate>Sat, 04 Oct 2008 00:13:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Combine-hundreds-of-sas7bdat/m-p/51458#M10795</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2008-10-04T00:13:09Z</dc:date>
    </item>
  </channel>
</rss>

