<?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: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515603#M139147</link>
    <description>&lt;P&gt;There's no way we can answer your question about omitting observations unless we see your code and a reasonable portion of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Click on the running man icon and paste your code in that window. Show us a portion of your data via creating SAS code to create the data sets, as shown here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 23 Nov 2018 16:39:43 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-11-23T16:39:43Z</dc:date>
    <item>
      <title>MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515594#M139140</link>
      <description>&lt;P&gt;NO CONTRY 1 &amp;amp; CONTRY 4 IN DATA YAYA ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS&lt;/P&gt;&lt;P&gt;8 LIBNAME XXX 'c:\users\wagdy';&lt;/P&gt;&lt;P&gt;NOTE: Libref XXX was successfully assigned as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Engine:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V9&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Physical Name: c:\users\wagdy&lt;/P&gt;&lt;P&gt;129&amp;nbsp;&amp;nbsp; DATA XXX.YAYA;&lt;/P&gt;&lt;P&gt;130&amp;nbsp;&amp;nbsp; MERGE XXX.orignal4 XXX.KARIMI2; BY SS_; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: There were 856 observations read from the data set XXX.ORIGNAL4.&lt;/P&gt;&lt;P&gt;NOTE: There were 388 observations read from the data set XXX.KARIMI2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: The data set XXX.YAYA has 857 observations and 402 variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; real time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.06 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpu time&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.03 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;WHEY THE TOTAL IN XXX.YAYA IS 857 NOT 1244? REGARDS. WAGDY&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 16:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515594#M139140</guid>
      <dc:creator>wagdy</dc:creator>
      <dc:date>2018-11-23T16:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515598#M139144</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/241071"&gt;@wagdy&lt;/a&gt;&amp;nbsp; how many records do you think you should have?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;129&amp;nbsp;&amp;nbsp; DATA XXX.YAYA;&lt;/P&gt;
&lt;P&gt;130&amp;nbsp;&amp;nbsp; MERGE XXX.orignal4 XXX.KARIMI2; BY SS_; RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: There were 856 observations read from the data set XXX.ORIGNAL4.&lt;/P&gt;
&lt;P&gt;NOTE: There were 388 observations read from the data set XXX.KARIMI2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The data set XXX.YAYA has 857 observations and 402 variables.&lt;/P&gt;
&lt;P&gt;try this is that what you are expecting? &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA XXX.YAYA; 
MERGE XXX.orignal4 (in=ina)
XXX.KARIMI2; 
BY SS_; 
if ina;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't think you want to do this but if you are just trying to stack the 2 datasets together&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xxx.yaya;
set xxx.orignal4 xxx.karimi2;
run;
proc sort data=xxx.yaya;
by SS_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 16:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515598#M139144</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2018-11-23T16:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515603#M139147</link>
      <description>&lt;P&gt;There's no way we can answer your question about omitting observations unless we see your code and a reasonable portion of your data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Click on the running man icon and paste your code in that window. Show us a portion of your data via creating SAS code to create the data sets, as shown here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 16:39:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515603#M139147</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-11-23T16:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515618#M139159</link>
      <description>&lt;P&gt;1. Merge combines two observations based on common grounds. Here, make sure you are sorting the "by" variable _ss.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, since it's merging ok without any errors, you are okay there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2: The number of observations is based on the "common variables". So, it keeps only that's common between the two. Please use in=dataset in your merge statement to make sure you end up with what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 3: There are several resources online to understand the difference between set and merge. Basically, set combines both datasets together (doesn't need common "by" variable) and puts them on top of one another. This will result in what you are looking for. But make sure that's what you need.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 17:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515618#M139159</guid>
      <dc:creator>saslove</dc:creator>
      <dc:date>2018-11-23T17:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515622#M139160</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;WHY THE TOTAL IN XXX.YAYA IS 857 NOT 1244?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Because you MERGEd the datasets instead of just stacking them.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;NOTE: There were 856 observations read from the data set XXX.ORIGNAL4.
NOTE: There were 388 observations read from the data set XXX.KARIMI2.

NOTE: The data set XXX.YAYA has 857 observations and 402 variables.&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;It looks like there was one value of SS_ in KARIMI2 that was not in ORIGNAL4 so the number of records increased by one. Another posibility is that one of the values of SS_ in KARIMI2 had one more observation than that value of SS_ had in ORIGNAL4.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you just want to stack the datasets together instead of merging them then use the SET statement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xxx.yaya;
  set xxx.orignal4 xxx.karimi2;
  by ss_;
run;&lt;/CODE&gt;&lt;/PRE&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;</description>
      <pubDate>Fri, 23 Nov 2018 17:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515622#M139160</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-11-23T17:07:35Z</dc:date>
    </item>
    <item>
      <title>Re: MERGED TWO FILES BUT THE NEW FILE OMTING MANY OBSERVATIONS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515627#M139162</link>
      <description>&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;suggests, you appear to want to interleave records from 2 data sets instead of match-merging them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I.e. you want the analog of the second program below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mostrecent_asof_2018OCT;
  merge mostrecent_asof_2018SEP  updates_for_2018OCT;
  by id;
run;


** versus **;
data complete_history_through_2018OCT;
  set complete_history_through_2018SEP upodates_for_2018OCT;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first program REPLACES data in mostrecent_asof_2018SEP (the "old master") with matching observations in updates_for_2018OCT (the "update data set"), and only increases the number of obs in the resulting dataset for (1) records in the update data set having id's absent from the old master,&amp;nbsp;and (2) instances in which a given ID has more records in the update data set than in the old master.&amp;nbsp; BTW, condition (2) is usually a reason why you would only want to use this approach when there is never more than one record per BY-variable (or per list of BY variables) in both data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second program INTERLEAVES observations, your apparent goal.&amp;nbsp; So the new number of observations exactly equals the sum of the number of obs in the incoming data sets.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 18:22:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/MERGED-TWO-FILES-BUT-THE-NEW-FILE-OMTING-MANY-OBSERVATIONS/m-p/515627#M139162</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-11-23T18:22:58Z</dc:date>
    </item>
  </channel>
</rss>

