<?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: Got a problem in merging in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598320#M8178</link>
    <description>Examine the results by running a PROC PRINT without then with this statement:&lt;BR /&gt;&lt;BR /&gt;format country $hex32.;</description>
    <pubDate>Tue, 22 Oct 2019 05:45:09 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2019-10-22T05:45:09Z</dc:date>
    <item>
      <title>Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598300#M8171</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I have a data set "world" which include 256 countries and continent. And another data set "have" include 125 countries and other variable. Now I want to attach the continent information to data"have".&lt;/P&gt;
&lt;P&gt;So my code is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=world;&lt;BR /&gt;by country;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;BR /&gt;by country;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data attached;&lt;BR /&gt;merge have world;&lt;BR /&gt;by country;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the result is something like&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;country&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variables&amp;nbsp; &amp;nbsp; &amp;nbsp; continent&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&lt;SPAN&gt;Armenia&lt;/SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; China&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; Korea&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;126&amp;nbsp; &lt;SPAN&gt;Armenia&lt;/SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Asia&lt;/P&gt;
&lt;P&gt;127&amp;nbsp; China&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Asia&lt;/P&gt;
&lt;P&gt;128&amp;nbsp; Korea&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Asia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I want is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;country&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; variables&amp;nbsp; &amp;nbsp; &amp;nbsp; continent&lt;/P&gt;
&lt;P&gt;1&amp;nbsp;&lt;SPAN&gt;Armenia&lt;/SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Asia&lt;/P&gt;
&lt;P&gt;2&amp;nbsp; China&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Asia&lt;/P&gt;
&lt;P&gt;3&amp;nbsp; Korea&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Asia&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does my code have problem ?? Anyone could modify my code to get what I want?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THANK YOU&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 03:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598300#M8171</guid>
      <dc:creator>YangYY</dc:creator>
      <dc:date>2019-10-22T03:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598309#M8173</link>
      <description>&lt;P&gt;It looks like the country names don't really match. Maybe you have invisible characters (tabs?) or leading spaces as part of the country names in one of the datasets.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 04:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598309#M8173</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-10-22T04:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598312#M8174</link>
      <description>&lt;P&gt;I checked the output data and I did not see the countries have leading space(for both of them). How should I modify my code to solve this problem??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 04:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598312#M8174</guid>
      <dc:creator>YangYY</dc:creator>
      <dc:date>2019-10-22T04:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598315#M8175</link>
      <description>&lt;P&gt;Have you checked if your country variable has a format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can run a proc contents to see that as follows :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data= have ;
run;
proc contents data= world ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Oct 2019 04:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598315#M8175</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2019-10-22T04:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598316#M8176</link>
      <description>&lt;P&gt;I don't think they have a format. What format they are supposed to have? How should I add a format to them?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 04:58:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598316#M8176</guid>
      <dc:creator>YangYY</dc:creator>
      <dc:date>2019-10-22T04:58:04Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598320#M8178</link>
      <description>Examine the results by running a PROC PRINT without then with this statement:&lt;BR /&gt;&lt;BR /&gt;format country $hex32.;</description>
      <pubDate>Tue, 22 Oct 2019 05:45:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598320#M8178</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-10-22T05:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598321#M8179</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/284230"&gt;@YangYY&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I don't think they have a format.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Don't &lt;EM&gt;think&lt;/EM&gt;. &lt;U&gt;KNOW&lt;/U&gt;. Run proc contents. This will reveal types, lengths and formats.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do a join or merge on character variables, they must have identical values. This means the join is case-sensitive.&lt;/P&gt;
&lt;P&gt;How did you inspect your columns? The best way to find erratic characters is to create a new variable where you store the hex coding.&lt;/P&gt;
&lt;P&gt;Suppose your country column has a length of 10, then do this (in both datasets):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length country_hex $20;
country_hex = put(country, $hex20.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can have a very clear picture of the contents.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 05:46:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598321#M8179</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-22T05:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: Got a problem in merging</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598326#M8180</link>
      <description>&lt;P&gt;I have found a solution with using the strip function to remove the leading blank. So SAS can recognize two countries variables are the same and the merge would work.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2019 06:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Got-a-problem-in-merging/m-p/598326#M8180</guid>
      <dc:creator>YangYY</dc:creator>
      <dc:date>2019-10-22T06:20:48Z</dc:date>
    </item>
  </channel>
</rss>

