<?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: Combining datasets in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468199#M14642</link>
    <description>&lt;P&gt;"Failed"&amp;nbsp;is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jun 2018 21:30:33 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-06-06T21:30:33Z</dc:date>
    <item>
      <title>Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468188#M14639</link>
      <description>&lt;P&gt;Hello everyone i'm working on a project to combine two datasets which I successfully imported into sas&amp;nbsp;separately.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first dataset is census data for an entire state by county and so each county is listed with its corresponding population estimate.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second dataset is data that lists the number of teachers per county with many other variables. I am trying to merge these two datasets but using the merge statement is not matching them correctly. Both datasets are sorted by county. I also tried proc SQL and nothing. Any ideas? below is my syntax.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im&amp;nbsp;running version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Failed merge:&lt;/P&gt;&lt;P&gt;data CM;&lt;BR /&gt;merge One Two;&lt;BR /&gt;by cou;&lt;BR /&gt;run;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Failed proc sql:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table cmt as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from One a&lt;/P&gt;&lt;P&gt;join Two b&amp;nbsp;&lt;/P&gt;&lt;P&gt;on a.cou=b.cou;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;M&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 20:52:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468188#M14639</guid>
      <dc:creator>Missmichelle</dc:creator>
      <dc:date>2018-06-06T20:52:06Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468192#M14640</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The second dataset is data that lists the number of teachers per county with many other variables. I am trying to merge these two datasets but using the merge statement is not matching them correctly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What does not matching them correctly mean? Can you&amp;nbsp;provide examples of records where you would like to see a match and it doesn't match? Matches are case sensitive so 'sas' is not the same as 'SAS'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 21:03:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468192#M14640</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-06-06T21:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468193#M14641</link>
      <description>&lt;P&gt;Your codes seem to be OK. Please post some example data against which we can test code (see my footnotes for how to do it).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 21:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468193#M14641</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-06T21:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468199#M14642</link>
      <description>&lt;P&gt;"Failed"&amp;nbsp;is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 21:30:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468199#M14642</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-06T21:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468211#M14643</link>
      <description>&lt;P&gt;1. I suggest you stick with PROC SQL for this kind of merge. I think you'll find it conceptually simpler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. From your description, it sounds like you should have one record per county id in each file. If you have more in one file, or much worse both files, you're going to get confusing results. You might want to check that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jun 2018 22:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468211#M14643</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-06-06T22:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468348#M14648</link>
      <description>&lt;P&gt;&lt;!--   Google Tag Manager   --&gt;&lt;!--   End Google Tag Manager   --&gt;Hello ,&lt;/P&gt;&lt;P&gt;a)Did you write appropriate type of join in the proc sql..&lt;/P&gt;&lt;P&gt;that might help the case...&lt;/P&gt;&lt;P&gt;Like ....&amp;nbsp; 'inner' or 'left' or 'right' .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For eg. below..&lt;/P&gt;&lt;P&gt;b) Are the datatype and length of county in both datsaets same ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-page"&gt;&lt;CENTER&gt;&lt;DIV class="MinimumWidthContainer"&gt;&lt;DIV class="min-width-wrapper"&gt;&lt;DIV class="min-width"&gt;&lt;DIV class="lia-content"&gt;&lt;DIV class="lia-quilt lia-quilt-forum-topic-page lia-quilt-layout-two-column-main-side lia-top-quilt"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-18 lia-quilt-column-left lia-quilt-column-main-content"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-component-message-list"&gt;&lt;DIV class="linear-message-list message-list"&gt;&lt;DIV class="lia-linear-display-message-view"&gt;&lt;DIV class="first-message"&gt;&lt;DIV class="lia-message-view message-uid-468188"&gt;&lt;DIV&gt;&lt;DIV class="lia-js-resize-images lia-component-forums-widget-board-message-view"&gt;&lt;DIV&gt;&lt;DIV class="lia-panel-message-root lia-message-board lia-panel-message lia-js-data-messageUid-468188"&gt;&lt;DIV class="lia-panel-message-content"&gt;&lt;DIV class="lia-decoration-border"&gt;&lt;DIV class="lia-decoration-border-content"&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-quilt lia-quilt-forum-message lia-quilt-layout-forum-message"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-forum-message-main"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;Proc sql;&lt;/P&gt;&lt;P&gt;create table cmt as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from One a&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inner&lt;/STRONG&gt; join Two&lt;/P&gt;&lt;P&gt;on a.cou=b.cou;quit;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/CENTER&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 07 Jun 2018 13:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468348#M14648</guid>
      <dc:creator>NeerajS1104</dc:creator>
      <dc:date>2018-06-07T13:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468388#M14649</link>
      <description>&lt;P&gt;Thank you so so much!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 14:36:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/468388#M14649</guid>
      <dc:creator>Missmichelle</dc:creator>
      <dc:date>2018-06-07T14:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Combining datasets</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/469997#M14687</link>
      <description>&lt;P&gt;Couple of thoughts.&lt;/P&gt;&lt;P&gt;First make sure each county is unique.&amp;nbsp; Many Counties have the same name in different states.&amp;nbsp; For example, there is an Orange County, TX and Orange County, CA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You may need to get the variable State into your Teacher dataset and use both State and County to preform the merge.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table cmt as&amp;nbsp;&lt;/P&gt;&lt;P&gt;select * from One a&lt;/P&gt;&lt;P&gt;FULL join Two b&amp;nbsp;&lt;/P&gt;&lt;P&gt;on a.cou=b.cou and a.STATE = b.STATE;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will get a message about variables that are in both datasets.&amp;nbsp; You might want to consider doing a COALESCE() on those variables that are in both for example cou and state.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Carry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 16:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Combining-datasets/m-p/469997#M14687</guid>
      <dc:creator>Carry</dc:creator>
      <dc:date>2018-06-13T16:53:41Z</dc:date>
    </item>
  </channel>
</rss>

