<?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: Attaching variable from another dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183130#M265363</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure, may be not understood properly. Your own syntax for sql can generate what you are trying to get.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table db3&lt;/P&gt;&lt;P&gt;&amp;nbsp; as select db1.*, db2.V3&lt;/P&gt;&lt;P&gt;&amp;nbsp; from db1, db2&lt;/P&gt;&lt;P&gt;&amp;nbsp; where db1.id = db2.id and db1.date = db2.date;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Sep 2014 16:59:16 GMT</pubDate>
    <dc:creator>stat_sas</dc:creator>
    <dc:date>2014-09-02T16:59:16Z</dc:date>
    <item>
      <title>Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183127#M265360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following two datasets (both sorted with respect to the variables id and date):&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data db1;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;input id date V1 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;V2&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;datalines;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.1&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;20110903&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.8&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data db2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;nput id date V3&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;datalines;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110901&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110901&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;I would like to obtain the following dataset db3:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data db3;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt;"&gt;input id date V1 &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;V2 V3&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;datalines;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;20110903&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.8&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;That is, I would like to add the variable V3 to the first dataset db1 when the values of the variables ID and DATE in db1 coincide with those in db2. Hence, the third dataset must have the size of the first one.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I have done two attempts. The first one involves PROC SQL&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table db3&lt;/P&gt;&lt;P&gt;&amp;nbsp; as select db1.*, db2.V3&lt;/P&gt;&lt;P&gt;&amp;nbsp; from db1, db2&lt;/P&gt;&lt;P&gt;&amp;nbsp; where db1.id = db2.id and db1.date = db2.date;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;The second one involves a simple merge with respect to both key variables&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P&gt;data db3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge db1 db2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Any help would be highly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 15:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183127#M265360</guid>
      <dc:creator>mark_ph</dc:creator>
      <dc:date>2014-09-02T15:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183128#M265361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data db3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge db1&lt;STRONG&gt;(in=a)&lt;/STRONG&gt; db2&lt;STRONG&gt;(in=b)&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id date;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; if a;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 15:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183128#M265361</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-09-02T15:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183129#M265362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And an SQL&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table db3&lt;/P&gt;&lt;P&gt;&amp;nbsp; as select db1.*, db2.V3&lt;/P&gt;&lt;P&gt;&amp;nbsp; from db1 left join db2&lt;/P&gt;&lt;P&gt;&amp;nbsp; on db1.id = db2.id and db1.date = db2.date;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 16:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183129#M265362</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-09-02T16:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183130#M265363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure, may be not understood properly. Your own syntax for sql can generate what you are trying to get.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table db3&lt;/P&gt;&lt;P&gt;&amp;nbsp; as select db1.*, db2.V3&lt;/P&gt;&lt;P&gt;&amp;nbsp; from db1, db2&lt;/P&gt;&lt;P&gt;&amp;nbsp; where db1.id = db2.id and db1.date = db2.date;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Sep 2014 16:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183130#M265363</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2014-09-02T16:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183131#M265364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you guys for all your kind replies.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="9792" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt; Unfortunately, your solution doesn't allow me to get the desired result. I have found a potential solution in this discussion where you replied years ago: &lt;A __default_attr="125069" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data db3;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;merge db1 db2;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;by id date;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;if not missing (V1) then output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;call missing(&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;V1&lt;/SPAN&gt;);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="260198" __jive_macro_name="user" class="jive_macro jive_macro_user" href="https://communities.sas.com/"&gt;&lt;/A&gt;, I obtain the number of rows of db2, instead of db1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;H6 style="font-weight: normal; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/H6&gt;&lt;P&gt;@stat@sas You are right. This solution works for my reproducible example. However, it does not for my real dataset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 13:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183131#M265364</guid>
      <dc:creator>mark_ph</dc:creator>
      <dc:date>2014-09-04T13:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching variable from another dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183132#M265365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i just checked the code i suggested to you and i see it is producing your expected output. like it is generating the same number of observations similar to db1 by matching on id and date variables. could you please again check and correct me. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data db1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id date V1 V2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data db2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input id date V3;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110901&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110901&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 60&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110902&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20110903&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=db1;&lt;/P&gt;&lt;P&gt;by id date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=db2;&lt;/P&gt;&lt;P&gt;by id date;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data db3;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge db1(in=a) db2(in=b);&lt;/P&gt;&lt;P&gt;&amp;nbsp; by id date;&lt;/P&gt;&lt;P&gt;if a;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" src="https://communities.sas.com/" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jag&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Sep 2014 15:59:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Attaching-variable-from-another-dataset/m-p/183132#M265365</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2014-09-04T15:59:13Z</dc:date>
    </item>
  </channel>
</rss>

