<?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/Joining Datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361350#M85199</link>
    <description>&lt;P&gt;Why not multiple sorts (with embedded variable renames), and one merge?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a (rename=(member_count=amember));
  by zip;
run;
proc sort data=b (rename=(member_count=bmember));
  by zip;
run;
proc sort data=c (rename=(script_count=cscript));
  by zip;
run;
proc sort data=d (rename=(script_count=dscript));
  by zip;
run;

data want;
  merge a b c d;
  by zip;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 May 2017 19:29:58 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2017-05-24T19:29:58Z</dc:date>
    <item>
      <title>Merging/Joining Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361345#M85195</link>
      <description>&lt;P&gt;Here is my sample data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  input ZIP Member_Count;
datalines;
1254 234
9936 123
7529 454
9154 678
;
run;

data b;
  input ZIP Member_Count;
datalines;
2156 555
9936 433
3346 225
9154 782
;
run;

data c;
  input ZIP Script_Count;
datalines;
2156 232
2299 656
2222 222
9154 690
;
run;

data d;
  input ZIP Script_Count;
datalines;
2156 555
9936 433
9154 225
2290 782
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here is what I want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  input ZIP amember bmember cscripts dscripts;
datalines;
1254 234 . . .
9936 123 433 . 433
7529 454 . . .
9154 678 782 690 225
2156 . 555 232 555
2299 . . 656 .
2222 . . 222 .
2290 . . . 782
3346 . 225 . .
;;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I want to combine the data from each dataset but keep distinct ZIP Codes and put values for each zip in columns after it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;The order of the ZIPS in the output dataset doesn't matter.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 19:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361345#M85195</guid>
      <dc:creator>JediApprentice</dc:creator>
      <dc:date>2017-05-24T19:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Merging/Joining Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361349#M85198</link>
      <description>&lt;P&gt;First, sort each data set by ZIP.&amp;nbsp; Then combine them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;merge a (rename=(member_count=amember))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; b (rename=(member_count=bmember))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; c&amp;nbsp;(rename=(script_count=cscripts))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; d (rename=(script_count=dscripts));&lt;/P&gt;
&lt;P&gt;by zip;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can also be done using SQL, in straightforward fashion if that is your preferred tool.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 19:29:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361349#M85198</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-24T19:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: Merging/Joining Datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361350#M85199</link>
      <description>&lt;P&gt;Why not multiple sorts (with embedded variable renames), and one merge?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a (rename=(member_count=amember));
  by zip;
run;
proc sort data=b (rename=(member_count=bmember));
  by zip;
run;
proc sort data=c (rename=(script_count=cscript));
  by zip;
run;
proc sort data=d (rename=(script_count=dscript));
  by zip;
run;

data want;
  merge a b c d;
  by zip;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 May 2017 19:29:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-Joining-Datasets/m-p/361350#M85199</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-05-24T19:29:58Z</dc:date>
    </item>
  </channel>
</rss>

