<?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: merge conflicts in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678260#M23835</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52150"&gt;@rajeshm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;found few same records are in&amp;nbsp; "onlyfirst" and&amp;nbsp; "onlysecond". but it is missing&amp;nbsp; "both".can somebody explain me how it is possible?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code is examining which data sets each record comes from. The In= option creates a variable that is true when the current observation contains a record from that data set and false otherwise.&lt;/P&gt;
&lt;P&gt;So when the current observation only comes from one set in these cases those records only go to the indicated output dataset.&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;else if first and not second then output onlyfirst;
else if second and not first then output onlysecond;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above ONLY gets executed when observations do not contain records from both data sets.&lt;/P&gt;</description>
    <pubDate>Thu, 20 Aug 2020 20:19:52 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-08-20T20:19:52Z</dc:date>
    <item>
      <title>merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678242#M23832</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;found few same records are in&amp;nbsp; "onlyfirst" and&amp;nbsp; "onlysecond". but it is missing&amp;nbsp; "both".can somebody explain me how it is possible?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;data both onlyfirst onlysecond;
merge xx(in=first) yy(in=second);
by _all_;
if first and second then output both;
else if first and not second then output onlyfirst;
else if second and not first then output onlysecond;
run;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 19:50:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678242#M23832</guid>
      <dc:creator>rajeshm</dc:creator>
      <dc:date>2020-08-20T19:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678249#M23833</link>
      <description>&lt;P&gt;I don't see anything wrong with your logic, or syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show the log please, and perhaps you can provide a sample of the offending records in XX and YY, in a data step.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 19:58:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678249#M23833</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-08-20T19:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678250#M23834</link>
      <description>It means you don't have identical records in both data sets.</description>
      <pubDate>Thu, 20 Aug 2020 19:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678250#M23834</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-08-20T19:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678260#M23835</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52150"&gt;@rajeshm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;found few same records are in&amp;nbsp; "onlyfirst" and&amp;nbsp; "onlysecond". but it is missing&amp;nbsp; "both".can somebody explain me how it is possible?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The code is examining which data sets each record comes from. The In= option creates a variable that is true when the current observation contains a record from that data set and false otherwise.&lt;/P&gt;
&lt;P&gt;So when the current observation only comes from one set in these cases those records only go to the indicated output dataset.&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;else if first and not second then output onlyfirst;
else if second and not first then output onlysecond;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The above ONLY gets executed when observations do not contain records from both data sets.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Aug 2020 20:19:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678260#M23835</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-08-20T20:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678388#M23842</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data both onlyA onlyB
merge datasetA(in=first) datasetB(in=second);
by sumtotal dT SYS PR AGT PID DATE;
if first and second then output both;
else if first and not second then output onlyA 
else if second and not first then output onlyB
run;&lt;/PRE&gt;
&lt;P&gt;WARNING: Multiple lengths were specified for the BY variable sys by input data sets. This might cause&lt;BR /&gt;unexpected results.&lt;BR /&gt;WARNING: Multiple lengths were specified for the BY variable pr by input data sets. This might&lt;BR /&gt;cause unexpected results.&lt;BR /&gt;WARNING: Multiple lengths were specified for the BY variable agt by input data sets. This might&lt;BR /&gt;cause unexpected results.&lt;BR /&gt;WARNING: Multiple lengths were specified for the BY variable pid by input data sets. This might&lt;BR /&gt;cause unexpected results.&lt;BR /&gt;NOTE: MERGE statement has more than one data set with repeats of BY values.&lt;BR /&gt;NOTE: There were &lt;FONT color="#0000FF"&gt;&lt;U&gt;423581&lt;/U&gt;&lt;/FONT&gt; observations read from the data set WORK.datasetA.&lt;BR /&gt;NOTE: There were &lt;FONT color="#0000FF"&gt;&lt;U&gt;420182&lt;/U&gt;&lt;/FONT&gt; observations read from the data set WORK.datasetB.&lt;BR /&gt;NOTE: The data set WORK.BOTH has &lt;FONT color="#0000FF"&gt;&lt;U&gt;376201&lt;/U&gt;&lt;/FONT&gt; observations and 7 variables.&lt;BR /&gt;NOTE: The data set WORK.onlyA has &lt;FONT color="#0000FF"&gt;&lt;U&gt;47380&lt;/U&gt;&lt;/FONT&gt; observations and 7 variables.&lt;BR /&gt;NOTE: The data set WORK.ONLYP5 has &lt;FONT color="#0000FF"&gt;43981&lt;/FONT&gt; observations and 7 variables.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;------------log--------------------------------------------------------------------------------------&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;merge conflicts confirmation&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;I exported datasetA and datasetB seperately and then pasted these two in a new different excel(47380+43981 rows),Again imported in sas and used the proc sql to find the unique records and found only 3500+ unique records(means record may be in WORK.onlyA or may be in WORK.onlyB)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if any issues with log , how "both" contains that many number of records? I am totally confused can you help me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 09:41:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678388#M23842</guid>
      <dc:creator>rajeshm</dc:creator>
      <dc:date>2020-08-21T09:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678550#M23861</link>
      <description>&lt;P&gt;A simple example should help.&lt;/P&gt;
&lt;P&gt;Code below creates 2 datasets first and second, then merges them.&lt;/P&gt;
&lt;P&gt;Any observation in both first and second will be output to both (A, C &amp;amp; D)&lt;BR /&gt;Any observation in first only will be output to first (B)&lt;/P&gt;
&lt;P&gt;Any observation in second only will be output to second (E)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note I simplified the logic, you don't need the "and not second" or "and not first", after the first IF condition you would be left with only observations that are in one or the other dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first ;
	input id $ ;
cards ;
A
B
C
D
;
data second ;
	input id $ ;
cards ;
A
C
D
E
;

data both  first second ;
	merge first (in=first) second (in=second) ;
	by id ;
	if first and second then output both ;
	else if first then output first ;
	else output second ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Aug 2020 18:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678550#M23861</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2020-08-21T18:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678552#M23862</link>
      <description>There's a good lesson here to be learned, and that is to always simplify the problem, reducing the number of observations to something you can manage in your head.</description>
      <pubDate>Fri, 21 Aug 2020 18:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678552#M23862</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2020-08-21T18:58:39Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678651#M23872</link>
      <description>&lt;PRE&gt;amount=198.67 date=05JUL2020 sys=1234 prin=0000 agent=1000 promoid=DT25DAY date_prod=05JUL2020
&lt;STRONG&gt;first=1 second=0&lt;/STRONG&gt;
amount=198.67 date=05JUL2020 sys=1234 prin=0000 agent=1000 promoid=DT25DAY date_prod=05JUL2020
&lt;STRONG&gt;first=0 second=1
&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;same values in first and second dataset and log showing the same&amp;nbsp; but ....it killing me. please help me.&lt;/P&gt;
&lt;P&gt;first and second are datasets in varibles.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 07:47:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678651#M23872</guid>
      <dc:creator>rajeshm</dc:creator>
      <dc:date>2020-08-22T07:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678654#M23873</link>
      <description>&lt;P&gt;So you took nicely perfumed data (SAS) and pulled it through a stinking pile of rotten manure (Excel), and now you expect that it still smells nicely?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What for are you taking the Excel detour that renders your data unusable?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 08:41:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678654#M23873</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-22T08:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678674#M23875</link>
      <description>I have imported data from 2 dwh and created 2 datasets separately. Now my task is to know common records in 2 dwh and only fird dwh record count and only second dwh record count. So used above logic , but only first dwh is showing 47k and only second dwh showing as 45k and then used put option to know why this much variation and logged the put values and attached here already. For testing, exported both (only first and only second) and merged both as Excel and  again imported and with my code, found only 3k unique records . &lt;BR /&gt;Q1  log/put values are same but finally it is showing as record in only first dwh and not in second and vice-versa.</description>
      <pubDate>Sat, 22 Aug 2020 16:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678674#M23875</guid>
      <dc:creator>rajeshm</dc:creator>
      <dc:date>2020-08-22T16:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678675#M23876</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/52150"&gt;@rajeshm&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;amount=198.67 date=05JUL2020 sys=1234 prin=0000 agent=1000 promoid=DT25DAY date_prod=05JUL2020
&lt;STRONG&gt;first=1 second=0&lt;/STRONG&gt;
amount=198.67 date=05JUL2020 sys=1234 prin=0000 agent=1000 promoid=DT25DAY date_prod=05JUL2020
&lt;STRONG&gt;first=0 second=1
&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;same values in first and second dataset and log showing the same&amp;nbsp; but ....it killing me. please help me.&lt;/P&gt;
&lt;P&gt;first and second are datasets in varibles.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What are the BY variables here?&amp;nbsp; All of them?&amp;nbsp; Let's look for sources of mismatches.&lt;/P&gt;
&lt;P&gt;For the variable AMOUNT remember that decimal fractions (0.67) cannot be exactly represented in floating point numbers. Make sure to round them both to the same level of precision before compare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the DATE_PROD variable, if that is a date variable remember that the DATE9 format (any any date format) will ignore the decimal part of the number of days.&amp;nbsp; SAS stores datetime as number of seconds but&amp;nbsp;Excel stores datetime values as number of days and percent of 24 hours.&amp;nbsp; So if you imported datetime values as dates from EXCEL you might have a value like a value like&amp;nbsp;22,101.5 for noon on 05JUL2020 instead of just 22,101.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;If any of the variables are character then look for leading spaces, those normally are not displayed in listings and error messages.&amp;nbsp; You could use the $QUOTE format to have it print the values with quotes around it so that leading spaces would be more visible.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also look for invisible characters in character variables, like TAB, CR, LF, non-breaking space, nulls, etc.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 16:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678675#M23876</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-08-22T16:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: merge conflicts</title>
      <link>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678688#M23885</link>
      <description>&lt;P&gt;If you need to compare datasets between data warehouses that do not reside on the same server,&amp;nbsp;the easiest method is to copy the .sas7bdat file from one server to the other. If one (or both) of the DWH's is not running SAS, export to a text file and import that, so you can make sure that the variable attributes match before you start to compare.&lt;/P&gt;
&lt;P&gt;Excel files are the&amp;nbsp;&lt;STRONG&gt;WORST&lt;/STRONG&gt; option for this, by lightyears.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 18:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/merge-conflicts/m-p/678688#M23885</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-22T18:41:35Z</dc:date>
    </item>
  </channel>
</rss>

