<?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: Can I replace this join? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493739#M129941</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date $ product $ supermarket $ price $;
datalines;
01JAN01 1 x 1.00
01JAN01 1 y 1.20
01JAN01 2 x 2.00
01FEB01 1 x 3.00
01FEB01 1 b 3.50
01MAR01 1 y 1.00
01MAR01 2 z 1.50
01MAR01 3 z 2.00
;
run;
proc sort data=have;
by date product;
run;
data want;
 merge have have( rename=(supermarket=_s price=price_x) where=(_s='x'));
 by date product;
 drop _s;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 08 Sep 2018 11:19:13 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-09-08T11:19:13Z</dc:date>
    <item>
      <title>Can I replace this join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493737#M129940</link>
      <description>&lt;P&gt;Hey guys, I have a further problem with SAS and I would really appreciate if someone could help me with this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the following dataset:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input date $ product $ supermarket $ price $;&lt;BR /&gt;datalines;&lt;BR /&gt;01JAN01 1 x 1.00&lt;BR /&gt;01JAN01 1 y 1.20&lt;BR /&gt;01JAN01 2 x 2.00&lt;BR /&gt;01FEB01 1 x 3.00&lt;BR /&gt;01FEB01 1 b 3.50&lt;BR /&gt;01MAR01 1 y 1.00&lt;BR /&gt;01MAR01 2 z 1.50&lt;BR /&gt;01MAR01 3 z 2.00&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The dataset contains observations of the prices, some supermarkets have in a specific month for a specific product.&lt;/P&gt;&lt;P&gt;For example, the first row says, that in January, the price for product 1 in supermarket x was 1 Dollar.&lt;/P&gt;&lt;P&gt;Now I want to add an additional column, for example price_of_x which contains the price of supermarket x for the specific product AND the specific month, or missing if no price is available in the data set. This could look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input date $ product $ supermarket $ price $ price_of_x $;&lt;BR /&gt;datalines;&lt;BR /&gt;01JAN01 1 x 1.00 1.00&lt;BR /&gt;01JAN01 1 y 1.20 1.00&lt;BR /&gt;01JAN01 2 x 2.00 2.00&lt;BR /&gt;01FEB01 1 x 3.00 3.00&lt;BR /&gt;01FEB01 1 b 3.50 3.00&lt;BR /&gt;01MAR01 1 y 1.00 .&lt;BR /&gt;01MAR01 2 z 1.50 .&lt;BR /&gt;01MAR01 3 z 2.00 .&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My attempt to do this was to create a subset of all observations of supermarket x and then to inner join it with the original dataset. Unfortunately, I have a really big dataset and need to do this join very often. Thus, I want to know if there is a more intelligent (in terms of performance) way to do this?&lt;/P&gt;&lt;P&gt;If it helps, in the next step I add 2 further columns agreement and disagreement. agreement gets the value 1 if the price is the same, otherwise its a disagreement. Maybe this could also be integrated in the solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&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;&lt;P&gt;Thanks in advance &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;mrzlatan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Sep 2018 11:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493737#M129940</guid>
      <dc:creator>mrzlatan91</dc:creator>
      <dc:date>2018-09-08T11:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Can I replace this join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493739#M129941</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input date $ product $ supermarket $ price $;
datalines;
01JAN01 1 x 1.00
01JAN01 1 y 1.20
01JAN01 2 x 2.00
01FEB01 1 x 3.00
01FEB01 1 b 3.50
01MAR01 1 y 1.00
01MAR01 2 z 1.50
01MAR01 3 z 2.00
;
run;
proc sort data=have;
by date product;
run;
data want;
 merge have have( rename=(supermarket=_s price=price_x) where=(_s='x'));
 by date product;
 drop _s;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Sep 2018 11:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493739#M129941</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-09-08T11:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can I replace this join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493740#M129942</link>
      <description>&lt;P&gt;Thank you very much, this is exactly what I was looking for&lt;/P&gt;</description>
      <pubDate>Sat, 08 Sep 2018 11:31:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-replace-this-join/m-p/493740#M129942</guid>
      <dc:creator>mrzlatan91</dc:creator>
      <dc:date>2018-09-08T11:31:12Z</dc:date>
    </item>
  </channel>
</rss>

