<?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 a dataset with duplicate identifiers to a panel data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-dataset-with-duplicate-identifiers-to-a-panel/m-p/429397#M106067</link>
    <description>&lt;P&gt;SQL does this fairly easily:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select dataset1.*, dataset2.date&lt;/P&gt;
&lt;P&gt;from dataset1, dataset2&lt;/P&gt;
&lt;P&gt;where dataset1.symbol = dataset2.symbol;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Jan 2018 17:15:48 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-01-20T17:15:48Z</dc:date>
    <item>
      <title>How to merge a dataset with duplicate identifiers to a panel data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-dataset-with-duplicate-identifiers-to-a-panel/m-p/429393#M106066</link>
      <description>&lt;P&gt;I have two datasets, call them dataset1 and dataset2. The first is a list of identifiers with character variable name "symbol", and there are duplicates in it. I use another variable "id" to order these symbols. The second is a panel data set with symbol and "year". For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data dataset1;
input id symbol $;
format id 1. symbol $2.;
datalines;
1 A
2 B
3 B
4 C
5 D
6 D
7 D
8 E
;
run;&lt;/PRE&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data dataset2;
length symbol $2 date 8;
informat symbol $2. date yymmdd.;
format symbol $2. date yymmddn8.;
input symbol $ date;
datalines;
A 20120101
A 20120102
A 20120103
B 20120101
B 20120102
C 20120102
C 20120103
C 20120104
D 20120101
D 20120102
D 20120103
D 20120104
E 20120102
E 20120103
;
run;

&lt;/PRE&gt;&lt;P&gt;My purpose is to merge the two datasets by "symbol", and each "id" in dataset1 should be merged with all corresponding symbol-date observations in dataset2. The merged data set should contain 24 observations. However, if I use&lt;/P&gt;&lt;PRE&gt;data want;
	merge dataset1 (in = a) dataset2 (in = b);
	by symbol;
	if a and b;
run;&lt;/PRE&gt;&lt;P&gt;I got only 14 observations. The reason is that, duplicate symbols in dataset1 are not treated as different IDs. How can I achieve the result I want?&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 16:55:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-dataset-with-duplicate-identifiers-to-a-panel/m-p/429393#M106066</guid>
      <dc:creator>xyxu</dc:creator>
      <dc:date>2018-01-20T16:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge a dataset with duplicate identifiers to a panel data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-dataset-with-duplicate-identifiers-to-a-panel/m-p/429397#M106067</link>
      <description>&lt;P&gt;SQL does this fairly easily:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;create table want as&lt;/P&gt;
&lt;P&gt;select dataset1.*, dataset2.date&lt;/P&gt;
&lt;P&gt;from dataset1, dataset2&lt;/P&gt;
&lt;P&gt;where dataset1.symbol = dataset2.symbol;&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jan 2018 17:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-merge-a-dataset-with-duplicate-identifiers-to-a-panel/m-p/429397#M106067</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-01-20T17:15:48Z</dc:date>
    </item>
  </channel>
</rss>

