<?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: Multiple datasets into one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260568#M50583</link>
    <description>&lt;P&gt;If you inspect carefully the names of all the data sets, you may be able to use a shorter program that uses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set test1.Region_201602: ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a shortcut that refers to all data set names beginning with the prior characters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't run this program twice.&amp;nbsp; If you actually create the combined data set using the name Region_201602, that name would be included in the list the next time you use the colon.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2016 21:37:17 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-03-31T21:37:17Z</dc:date>
    <item>
      <title>Multiple datasets into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260539#M50573</link>
      <description>&lt;P&gt;I have separate datasets located in a libname called test1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Region_20160201&lt;/P&gt;
&lt;P&gt;Region_20160202&lt;/P&gt;
&lt;P&gt;Region_20160203&lt;/P&gt;
&lt;P&gt;Region_20160204&lt;/P&gt;
&lt;P&gt;Region_20160205&lt;/P&gt;
&lt;P&gt;The numbers represent dates&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example datastep:&lt;/P&gt;
&lt;P&gt;data test1.Region_20160201;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Here is some sample data for each Region&lt;/P&gt;
&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; File_Date&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data_Type&lt;/P&gt;
&lt;P&gt;11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11/15/05&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R&lt;/P&gt;
&lt;P&gt;12&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 05/05/11&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; T&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a single data-set that combines all of the individual datasets based on the previous month. Therefore we would have this&lt;/P&gt;
&lt;P&gt;Region_201602 and then have all 5 datasets combined into one dataset.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 20:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260539#M50573</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2016-03-31T20:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple datasets into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260542#M50575</link>
      <description>&lt;P&gt;If you're just appending them then this will do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set
test1.Region_20160201
test1.Region_20160202
test1.Region_20160203
test1.Region_20160204
test1.Region_20160205
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But, are you wanting to pull the date of the file into the output data? I couldn't tell from your question.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 20:18:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260542#M50575</guid>
      <dc:creator>DanZ</dc:creator>
      <dc:date>2016-03-31T20:18:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple datasets into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260568#M50583</link>
      <description>&lt;P&gt;If you inspect carefully the names of all the data sets, you may be able to use a shorter program that uses:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;set test1.Region_201602: ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The colon is a shortcut that refers to all data set names beginning with the prior characters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Don't run this program twice.&amp;nbsp; If you actually create the combined data set using the name Region_201602, that name would be included in the list the next time you use the colon.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2016 21:37:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260568#M50583</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-03-31T21:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple datasets into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260635#M50615</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding﻿&lt;/a&gt;&amp;nbsp;has given you a good idea there. &amp;nbsp;I would just add that having "data" in table names - or column names - which are for programming purposes is not a good idea. &amp;nbsp;All you are doing is making your programming life harder. &amp;nbsp;If you need separate files then use a consitent prefix and incrementor, for example ds1, ds2 etc. &amp;nbsp;However in most cases, unless your data is huge then having one dataset with a varibale to identify dataset ould be far easier to work with:&lt;/P&gt;
&lt;PRE&gt;data total;
  set test1.region_2016: indsname=tmp;
  ds_name=input(tranwrd(tmp,"Region_",""),yymmdd8.);&lt;BR /&gt;  format ds_name date9.;
run;
&lt;/PRE&gt;
&lt;P&gt;The above will load all the datasets into one dataset called total, and in there you will have a variable with the date from filename. &amp;nbsp;Then you can process this one dataset - no need for looping or knowing lots of file names. &amp;nbsp;You can use by group processing on it. &amp;nbsp;You can use the date data for other calculations etc. &amp;nbsp;Data should go in a dataset, column names and dataset names are there to be used for programming, column labels and dataset labels are there for people to look at.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2016 08:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-datasets-into-one/m-p/260635#M50615</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-01T08:32:32Z</dc:date>
    </item>
  </channel>
</rss>

