<?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: Merging multiple CSV files to a dataset. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404579#M98343</link>
    <description>&lt;P&gt;Merge BY will take the values from the right most dataset on&amp;nbsp;the merge statement&amp;nbsp;with the named variable. So if work.B is missing a value for variable XYZZY, then the resulting data set will have a missing value for XYZZY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice in this example that the values for the variable B all come from dataset work.two except for the value of A that is not in work.two.&lt;/P&gt;
&lt;PRE&gt;data work.one;
   input a b;
datalines;
1 24
2 34
3 44
4 66
;
run;
data work.two;
   input a b;
datalines;
1  .
2  33
3  99
;
run;

data merged;
   merge work.one work.two;
   by a;
run;&lt;/PRE&gt;
&lt;P&gt;Expand this to 17 files it can get very difficult to guess which data set may be causing a specific missing result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the variables in the A datasets all supposed to be the same or do they have different variables in some?&lt;/P&gt;
&lt;P&gt;If a variable only has values in one data set, then if it doesn't contribute to all records on the BY variable value then those records without a match will be missing as well.&lt;/P&gt;</description>
    <pubDate>Mon, 16 Oct 2017 20:06:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-10-16T20:06:19Z</dc:date>
    <item>
      <title>Merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404522#M98330</link>
      <description>&lt;P&gt;Hi, I currently have 16 files with the similar names such as A1, A2, A3, etc, I also have a merge base file called B. What I want to do is merge 16 As files to B into one file. Suppose all the data is sorted and should be merged by date. I wrote the code for merging but doesn't work very well. The problem is some of the column variables in As are missing after merge. Does someone has any suggestion?&amp;nbsp;&lt;SPAN&gt;Any help with this will be appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is the code I wrote.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA work.Merged; 
	MERGE work.A: work.B; 										
	BY Date; 
RUN; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 16:56:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404522#M98330</guid>
      <dc:creator>Xusheng</dc:creator>
      <dc:date>2017-10-16T16:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404523#M98331</link>
      <description>&lt;P&gt;You need to post more details. Especially around:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;The problem is some of the column variables in As are missing after merge.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 16 Oct 2017 17:02:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404523#M98331</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-16T17:02:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404524#M98332</link>
      <description>&lt;P&gt;Do you&amp;nbsp;want to merge the datasets?&amp;nbsp; &amp;nbsp;Sounds more like you want a set.&amp;nbsp; Anyways, if variables appear in multiple datasets then they will only appear once from the first dataset.&amp;nbsp; Also, your date might not match across all datasets, if so the variables which would come from that dataset will be blank in the instance where there is no match.&amp;nbsp; Provide test data - in the form of a datastep, and put in the {i} tool above post - for further help.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 17:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404524#M98332</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-16T17:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Merging multiple CSV files to a dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404579#M98343</link>
      <description>&lt;P&gt;Merge BY will take the values from the right most dataset on&amp;nbsp;the merge statement&amp;nbsp;with the named variable. So if work.B is missing a value for variable XYZZY, then the resulting data set will have a missing value for XYZZY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Notice in this example that the values for the variable B all come from dataset work.two except for the value of A that is not in work.two.&lt;/P&gt;
&lt;PRE&gt;data work.one;
   input a b;
datalines;
1 24
2 34
3 44
4 66
;
run;
data work.two;
   input a b;
datalines;
1  .
2  33
3  99
;
run;

data merged;
   merge work.one work.two;
   by a;
run;&lt;/PRE&gt;
&lt;P&gt;Expand this to 17 files it can get very difficult to guess which data set may be causing a specific missing result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are the variables in the A datasets all supposed to be the same or do they have different variables in some?&lt;/P&gt;
&lt;P&gt;If a variable only has values in one data set, then if it doesn't contribute to all records on the BY variable value then those records without a match will be missing as well.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 20:06:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-multiple-CSV-files-to-a-dataset/m-p/404579#M98343</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-16T20:06:19Z</dc:date>
    </item>
  </channel>
</rss>

