<?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 Merging two datasets of different number of observations in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409097#M99924</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have one dataset that contains 1,000 observations and 50 variables - Data A.&lt;/P&gt;&lt;P&gt;I also have another dataset with only one observation and 30 variables - Data B.&lt;/P&gt;&lt;P&gt;The variables in Data B are parmeters that I want to add to all observations in Data A.&lt;/P&gt;&lt;P&gt;I tried to merge/set&amp;nbsp;the two datasets but it only gives me first observation in A with the 1 observation in B and the other observations with missing value.&lt;/P&gt;&lt;P&gt;As You can see in the photo, Data A ends with variable P1000 and Data B starts with variable SM.&lt;/P&gt;&lt;P&gt;My question is, How do I dulplicate the one observation in B so all the observations in A will have it as a variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matan.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 Oct 2017 13:17:07 GMT</pubDate>
    <dc:creator>Greisas</dc:creator>
    <dc:date>2017-10-31T13:17:07Z</dc:date>
    <item>
      <title>Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409097#M99924</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have one dataset that contains 1,000 observations and 50 variables - Data A.&lt;/P&gt;&lt;P&gt;I also have another dataset with only one observation and 30 variables - Data B.&lt;/P&gt;&lt;P&gt;The variables in Data B are parmeters that I want to add to all observations in Data A.&lt;/P&gt;&lt;P&gt;I tried to merge/set&amp;nbsp;the two datasets but it only gives me first observation in A with the 1 observation in B and the other observations with missing value.&lt;/P&gt;&lt;P&gt;As You can see in the photo, Data A ends with variable P1000 and Data B starts with variable SM.&lt;/P&gt;&lt;P&gt;My question is, How do I dulplicate the one observation in B so all the observations in A will have it as a variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Matan.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409097#M99924</guid>
      <dc:creator>Greisas</dc:creator>
      <dc:date>2017-10-31T13:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409098#M99925</link>
      <description>Do the merge using a BY statement.</description>
      <pubDate>Tue, 31 Oct 2017 13:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409098#M99925</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-31T13:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409100#M99926</link>
      <description>&lt;P&gt;To add one observation in B to all observations in A:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;if _n_=1 then set B;&lt;/P&gt;
&lt;P&gt;set A;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:31:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409100#M99926</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-31T13:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409103#M99928</link>
      <description>&lt;P&gt;Consider these two methods:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
input var1 var2 var3;
cards;
1 2 3
4 5 6
7 8 9
;
run;

data b;
input var4 var5;
cards;
10 11
;
run;

data want1;
set a;
_x_ = 1;
set b point=_x_;
run;

proc sql;
create table want2 as
select * from a,b;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The point=method rereads dataset b in every iteration, and therefore overrides the problem caused by the automatic "set to missing" that happens at the start of a datastep iteration.&lt;/P&gt;
&lt;P&gt;SQL will always build a cartesian product on its own.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:37:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409103#M99928</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-31T13:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409106#M99930</link>
      <description>Hi,&lt;BR /&gt;Thank you for the quick and helpful comments!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409106#M99930</guid>
      <dc:creator>Greisas</dc:creator>
      <dc:date>2017-10-31T13:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets of different number of observations</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409107#M99931</link>
      <description>Hi,&lt;BR /&gt;Thanks for the quick comment.&lt;BR /&gt;The problem is that Data A contains ID's, but Data B doesn't, so I can't use the BY statement.&lt;BR /&gt;Anyway, Astounding gave me a way.&lt;BR /&gt;Thanks again.</description>
      <pubDate>Tue, 31 Oct 2017 13:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-of-different-number-of-observations/m-p/409107#M99931</guid>
      <dc:creator>Greisas</dc:creator>
      <dc:date>2017-10-31T13:44:24Z</dc:date>
    </item>
  </channel>
</rss>

