<?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 merge dynamic datasets? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701677#M214889</link>
    <description>INDSNAME option on the SET statement + save it.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set ..... INDSNAME = source;&lt;BR /&gt;dataSource = source;&lt;BR /&gt;run;</description>
    <pubDate>Wed, 25 Nov 2020 19:43:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-11-25T19:43:40Z</dc:date>
    <item>
      <title>How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701620#M214866</link>
      <description>&lt;P&gt;Hello!!&lt;/P&gt;&lt;P&gt;I am quite new in SAS programming, so I have some doubts how to merge dynamic datasets.&lt;/P&gt;&lt;P&gt;I have a table containing a variable with the names of multiple datasets I would like to merge into one single dataset.&lt;/P&gt;&lt;P&gt;I would like to know how I can merge all these datasets. All of them are placed in the same library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 17:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701620#M214866</guid>
      <dc:creator>Sica</dc:creator>
      <dc:date>2020-11-25T17:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701624#M214868</link>
      <description>Is the merge complicated or just a simple BY statement?&lt;BR /&gt;&lt;BR /&gt;proc sql noprint;&lt;BR /&gt;select name into :merge_list separated by " " from listDatasets;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge &amp;amp;merge_list;&lt;BR /&gt;by commonVariable;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 25 Nov 2020 17:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701624#M214868</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-25T17:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701626#M214869</link>
      <description>&lt;P&gt;First question: Merge or Append?&lt;/P&gt;
&lt;P&gt;Merge in SAS usually refers to "horizontal" combining such as matching on a value.&lt;/P&gt;
&lt;P&gt;Append would mean "add to the end of" an existing data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second: Do variables of the same names have the same properties? If variable X is not numeric or character (either one) in all of the sets you will have a failure. If common variables are character you can get truncated data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best is provide some examples of the data and what the result should be.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 17:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701626#M214869</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T17:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701633#M214871</link>
      <description>Sorry, I would like to append.&lt;BR /&gt;&lt;BR /&gt;All the tables have the same columns. The library has more than 1000 datasets, and I would like to append around 80 of them. So I created a variable containing all the datasets I would like to append, but I do know how to it dynamically, only by typing dataset by dataset =/&lt;BR /&gt;I would like to do it in a smarter way.&lt;BR /&gt;&lt;BR /&gt;Thank you.</description>
      <pubDate>Wed, 25 Nov 2020 18:10:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701633#M214871</guid>
      <dc:creator>Sica</dc:creator>
      <dc:date>2020-11-25T18:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701638#M214872</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329497"&gt;@Sica&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Sorry, I would like to append.&lt;BR /&gt;&lt;BR /&gt;All the tables have the same columns. The library has more than 1000 datasets, and I would like to append around 80 of them. So I created a variable containing all the datasets I would like to append, but I do know how to it dynamically, only by typing dataset by dataset =/&lt;BR /&gt;I would like to do it in a smarter way.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It isn't clear what you mean by a "variable containing all the datasets".&lt;/P&gt;
&lt;P&gt;If you mean that you have a dataset containing the names you want as one observation per name then something like this will work if there are not problems with variable properties the same. Note, not efficient but simple code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
   select datasetnames into : namelist separated by ' '
   from datasetwithnames
   ;
run;

data want;
   set &amp;amp;namelist.;
run;&lt;/PRE&gt;
&lt;P&gt;Or if the names are "nice" such as common base name ending with sequence number you could use a list like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set dsname1 - dsname10;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;There are other ways to build lists depending on the values. It might help to show the names you are concerned with so we don't have to make a lot of guesses.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701638#M214872</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T18:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701641#M214874</link>
      <description>&lt;P&gt;Naming conventions would make this trivial so I'd highly recommend you pick a good naming convention.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And a slight modification to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;code in case you don't have the library included in the list of data set names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let myLibname = sashelp;
proc sql;
   select catx(".", "&amp;amp;myLibname.", datasetnames) into : namelist separated by ' '
   from datasetwithnames
   ;
run;

data want;
   set &amp;amp;namelist.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701641#M214874</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-25T18:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701642#M214875</link>
      <description>&lt;P&gt;If you can state a rule for selecting the datasets, then that rule can be made into code.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701642#M214875</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-25T18:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701675#M214888</link>
      <description>Thank you a lot!!&lt;BR /&gt;&lt;BR /&gt;Is there an easy way to create a column and add the original file name from all values?</description>
      <pubDate>Wed, 25 Nov 2020 19:34:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701675#M214888</guid>
      <dc:creator>Sica</dc:creator>
      <dc:date>2020-11-25T19:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701677#M214889</link>
      <description>INDSNAME option on the SET statement + save it.&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;set ..... INDSNAME = source;&lt;BR /&gt;dataSource = source;&lt;BR /&gt;run;</description>
      <pubDate>Wed, 25 Nov 2020 19:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701677#M214889</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-11-25T19:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701679#M214891</link>
      <description>Reeza, thanks a lot! It woks!! =o)</description>
      <pubDate>Wed, 25 Nov 2020 19:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701679#M214891</guid>
      <dc:creator>Sica</dc:creator>
      <dc:date>2020-11-25T19:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge dynamic datasets?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701680#M214892</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329497"&gt;@Sica&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you a lot!!&lt;BR /&gt;&lt;BR /&gt;Is there an easy way to create a column and add the original file name from all values?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The Set statement option INDSNAME name will do that. The default behavior is to create a &lt;STRONG&gt;temporary&lt;/STRONG&gt; variable, so you need to assign that value to a desired variable.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;data junk;
   set sashelp.class indsname=ds;
   source=ds;
run;&lt;/PRE&gt;
&lt;P&gt;DS is a temporary variable that holds the library and dataset name and will not be written to the output data set (that's what temporary means). Source is assigned the value of the variable DS and will be kept in the data. You only use the option one time and it really doesn't matter where it goes on the set statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 19:53:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-dynamic-datasets/m-p/701680#M214892</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-11-25T19:53:10Z</dc:date>
    </item>
  </channel>
</rss>

