<?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: Variables are merged but not the actual values are not merged in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157284#M1668</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Fugue! I was aware of the first concern but your second concern and suggestion actually made it work! &lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Jan 2014 21:17:09 GMT</pubDate>
    <dc:creator>Markov</dc:creator>
    <dc:date>2014-01-30T21:17:09Z</dc:date>
    <item>
      <title>Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157279#M1663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried to merge some variables with numerical values from one table(table b) to another table(table a) using SQL left join (on a.year=b.year and a.codeA=b.codeA and a.codeB=b.codeB).&lt;/P&gt;&lt;P&gt;What it returns me is the table with the variables what I wanted from table b (let's say INCOME AGE etc) but no numerical values from table b. I see no error message in log.&lt;/P&gt;&lt;P&gt;What could be the reason for this results?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;MB&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-------------------------------&lt;/P&gt;&lt;P&gt;Thanks for your replies, experts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the data sets (table a and table b) as well as result table where I am having trouble mentioned in the original discussion).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS Code I used is as the following;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql; create table sample_result&lt;/P&gt;&lt;P&gt;as select a.*, b.edu, b.mhincome, b.mage&lt;/P&gt;&lt;P&gt;from sample_a as a left join sample_b as b&lt;/P&gt;&lt;P&gt;on a.year=b.year and a.state_code=b.state_code and a.co_code=b.co_code;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;MB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 16:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157279#M1663</guid>
      <dc:creator>Markov</dc:creator>
      <dc:date>2014-01-30T16:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157280#M1664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, we're looking at neither your code nor your data so it's a bit of a guess.&amp;nbsp; Here are a couple of basic things to check.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does Table B actually contain non-missing data for INCOME, AGE, etc.?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are performing a LEFT JOIN, is it possible you are getting records from Table A that have no match in Table B?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are plenty of SQL gurus lurking here who might have better ideas if they could see your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:54:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157280#M1664</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2014-01-30T17:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157281#M1665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You probably did something wrong.&amp;nbsp; But we can't tell you what because you haven't told us what you did &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 17:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157281#M1665</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-30T17:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157282#M1666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are two potential problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are joining table B to table A using a LEFT JOIN. This means you will get all records in table A even if there are no matching rows in table B. This also means that you will not get rows in table B that do NOT exist in table A. This is fine if this is what you want.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, table A does not have a row where "state_code = 55 and co_code = 87 and year=1980". But, there is a corresponding row in table B. But, because you are left joining B to A, the resulting table will not have a row where "state_code = 55 and co_code = 87 and year=1980".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your second problem is probably why you are not getting the results you expect. Your two tables have inconsistent formats for variables in table A vs table B. In particular, the year variable in table B has a YEARw format whereas the same variable in table A is formatted BEST12. The table B format is interpreting the year variable as a date value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white;"&gt;proc&lt;/STRONG&gt;&lt;SPAN style="background: white;"&gt; &lt;STRONG style="color: navy;"&gt;sql&lt;/STRONG&gt;; &lt;SPAN style="color: blue;"&gt;create&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;table&lt;/SPAN&gt; sample_result2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue;"&gt;as&lt;/SPAN&gt;&lt;SPAN style="background: white;"&gt; &lt;SPAN style="color: blue;"&gt;select&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;a.&lt;/SPAN&gt;*, b.edu, b.mhincome, b.mage&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="background: white;"&gt; tmp2.sample_a &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt; a &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue;"&gt;left&lt;/SPAN&gt;&lt;SPAN style="background: white;"&gt; &lt;SPAN style="color: blue;"&gt;join&lt;/SPAN&gt; tmp3.sample_b &lt;SPAN style="color: blue;"&gt;as&lt;/SPAN&gt; b&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white; color: blue;"&gt;on&lt;/SPAN&gt;&lt;SPAN style="background: white;"&gt; put(a.year, &lt;STRONG style="color: teal;"&gt;4.0&lt;/STRONG&gt;) = put(b.year, &lt;SPAN style="color: teal;"&gt;year4.&lt;/SPAN&gt;) &lt;SPAN style="color: blue;"&gt;and&lt;/SPAN&gt; a.state_code=b.state_code &lt;SPAN style="color: blue;"&gt;and&lt;/SPAN&gt; a.co_code=b.co_code;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white;"&gt;quit&lt;/STRONG&gt;&lt;SPAN style="background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 20:09:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157282#M1666</guid>
      <dc:creator>Fugue</dc:creator>
      <dc:date>2014-01-30T20:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157283#M1667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To add to Fuge response, its that the underlying data is actually different. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=sample_b;&lt;/P&gt;&lt;P&gt;format year;&lt;/P&gt;&lt;P&gt;var year;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 20:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157283#M1667</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2014-01-30T20:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157284#M1668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Fugue! I was aware of the first concern but your second concern and suggestion actually made it work! &lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 21:17:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157284#M1668</guid>
      <dc:creator>Markov</dc:creator>
      <dc:date>2014-01-30T21:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Variables are merged but not the actual values are not merged</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157285#M1669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Reeza! Yes, I can now see that it was creating the trouble. I learned one lessen today &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Jan 2014 21:18:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/Variables-are-merged-but-not-the-actual-values-are-not-merged/m-p/157285#M1669</guid>
      <dc:creator>Markov</dc:creator>
      <dc:date>2014-01-30T21:18:04Z</dc:date>
    </item>
  </channel>
</rss>

