<?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: proc sql join and data merge both do not work in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539754#M148775</link>
    <description>&lt;P&gt;In general, FULL JOIN and LEFT JOIN don't have to produce the same results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When they don't produce the same results, this implies that the data sets have mismatches on the variables used in the join.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2019 19:45:17 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2019-03-01T19:45:17Z</dc:date>
    <item>
      <title>proc sql join and data merge both do not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539701#M148756</link>
      <description>&lt;P&gt;Hi Folks and &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt; ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I perform following joins many times a day to slightly exaggerate but it doesn't work today. I know that linkage variables have to have the same alignment and the format. I tried A and B in the code snippet with a variation of using LEFT(), RIGHT() and also am sure fips_tract, agecat and sex have identical length, format and informat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full join creates 70,338 observations and proc means produce min and max of count outcome correct. However,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Left join, the join form I need creates 68,684 observations and proc means produce missing values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The difference 1654 is the size of one of datasets here.&lt;/P&gt;
&lt;P&gt;What am I missing here? Any idea?&lt;/P&gt;
&lt;P&gt;Thanks a lot in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;PROC MEANS DATA=TR_EJ_KAPOSI MIN MAX MAXDEC=1; VAR N_TRACT; RUN; &lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;A.&lt;BR /&gt;PROC SQL; 
CREATE TABLE TR_EJ_KAPOSI AS SELECT
P.TRACT_POP, T.N_TRACT,P.FIPS_TRACT, P.AGECAT,P.SEX
FROM E.POP_AGESEX_RACE_POV_EJ1 P FULL JOIN TRACT_KAPOSI T 
ON RIGHT(P.FIPS_TRACT)=RIGHT(T.FIPS_TRACT) AND RIGHT(P.AGECAT)=RIGHT(T.AGECAT) AND RIGHT(P.SEX)=RIGHT(T.SEX);
QUIT; 
&lt;BR /&gt;B.
PROC SQL;
CREATE TABLE TR_EJ_KAPOSI AS SELECT
P.TRACT_POP, T.N_TRACT,P.FIPS_TRACT, P.AGECAT,P.SEX
FROM E.POP_AGESEX_RACE_POV_EJ1 P LEFT JOIN TRACT_KAPOSI T 
ON P.FIPS_TRACT=T.FIPS_TRACT AND P.AGECAT=T.AGECAT AND P.SEX=T.SEX;
QUIT; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 17:13:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539701#M148756</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-03-01T17:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql join and data merge both do not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539754#M148775</link>
      <description>&lt;P&gt;In general, FULL JOIN and LEFT JOIN don't have to produce the same results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When they don't produce the same results, this implies that the data sets have mismatches on the variables used in the join.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 19:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539754#M148775</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-01T19:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql join and data merge both do not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539756#M148777</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132289"&gt;@Cruise&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There must be something wrong with your input data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You get these results if your result data has only missing values in var.&amp;nbsp;&lt;SPAN&gt;N_TRACT, which happens with a left join where the condition is never true.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But with a full join you get extra observations from&amp;nbsp;TRACT_KAPOSI where the condition is not met, and these observations comes with values in&amp;nbsp;N_TRACT. it follows that&amp;nbsp;TRACT_KAPOSI must have 1654 observations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So even if FIPS_TRACT, AGECAT and SEX have same lengths, types and formats in both data sets, there are no observations with same &lt;U&gt;values&lt;/U&gt; of FIPS_TRACT, AGECAT and SEX in both data sets, and therefor no contribution from&amp;nbsp;TRACT_KAPOSI in a left join.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 19:49:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539756#M148777</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2019-03-01T19:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql join and data merge both do not work</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539767#M148785</link>
      <description>&lt;P&gt;Thanks a lot. This happened when I re-used my old codes without reviewing first. I changed my unit of analysis from block group to a tract and the last digit for the block group was not removed to become a fips_tract. Thank again.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 20:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-join-and-data-merge-both-do-not-work/m-p/539767#M148785</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2019-03-01T20:50:00Z</dc:date>
    </item>
  </channel>
</rss>

