<?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: Merging two datasets, one has a text column with length of 60? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698307#M213546</link>
    <description>&lt;P&gt;When you are using the MERGE statement for multiple datasets with common variables, the earliest (i.e. leftmost) discovery of the common variable will determine the attributes, like length, of the variable - even though the rightmost value will prevail.&amp;nbsp; So if you want the length of 60 to be propagated to the new dataset, make sure the incoming dataset with the length of 60 is mentioned first in the merge statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say you want to merge have1 and have2 with variables ID, A, B, C, X, Y, and Z in common.&amp;nbsp; But you want the length of variables X, Y, and Z from have2 to prevail, but you want the lengths of A, B, and C to be inherited from have1.&amp;nbsp; Then you could:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  if 0 then set have1 (drop=x y z) have2;
  merge have1 have2;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "if 0" statement is enountered by the sas compiler prior to the merge statement.&amp;nbsp; The compiler resolves it to produce lengths as I described above.&amp;nbsp; But since "if 0" is never true, the "then set ..." action is never performed.&amp;nbsp; Instead the MERGE statement does the actual work, with&lt;STRIKE&gt;out&lt;/STRIKE&gt; the lengths of X Y and Z determined by have2.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 05:44:55 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2020-11-12T05:44:55Z</dc:date>
    <item>
      <title>Merging two datasets, one has a text column with length of 60?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698303#M213542</link>
      <description>&lt;P&gt;SAS 9.4&lt;/P&gt;&lt;P&gt;I'm trying to merge two datasets and one column is giving me issues. This column ("county") is named the same in both datasets, but in one of them it has a length of 8 and in the other a length of 60. I believe this is causing issues with the merge. Any ideas on how I can change the 60 to 8 or 8 to 60?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="sascap.PNG" style="width: 480px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/51594i4793919B250E8440/image-size/large?v=v2&amp;amp;px=999" role="button" title="sascap.PNG" alt="sascap.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 04:40:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698303#M213542</guid>
      <dc:creator>sasDave</dc:creator>
      <dc:date>2020-11-12T04:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets, one has a text column with length of 60?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698307#M213546</link>
      <description>&lt;P&gt;When you are using the MERGE statement for multiple datasets with common variables, the earliest (i.e. leftmost) discovery of the common variable will determine the attributes, like length, of the variable - even though the rightmost value will prevail.&amp;nbsp; So if you want the length of 60 to be propagated to the new dataset, make sure the incoming dataset with the length of 60 is mentioned first in the merge statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say you want to merge have1 and have2 with variables ID, A, B, C, X, Y, and Z in common.&amp;nbsp; But you want the length of variables X, Y, and Z from have2 to prevail, but you want the lengths of A, B, and C to be inherited from have1.&amp;nbsp; Then you could:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  if 0 then set have1 (drop=x y z) have2;
  merge have1 have2;
  by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The "if 0" statement is enountered by the sas compiler prior to the merge statement.&amp;nbsp; The compiler resolves it to produce lengths as I described above.&amp;nbsp; But since "if 0" is never true, the "then set ..." action is never performed.&amp;nbsp; Instead the MERGE statement does the actual work, with&lt;STRIKE&gt;out&lt;/STRIKE&gt; the lengths of X Y and Z determined by have2.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 05:44:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698307#M213546</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-11-12T05:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets, one has a text column with length of 60?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698310#M213548</link>
      <description>&lt;P&gt;You should check why the same variable has been defined with different lengths during import and fix the problem in that stage of your project. If you can't change the importing code, ask the one who created it, there must be a reason, maybe you have state-codes in one dataset an state names in the other.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 05:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698310#M213548</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-11-12T05:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets, one has a text column with length of 60?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698360#M213573</link>
      <description>data want;&lt;BR /&gt;  length county $ 60;&lt;BR /&gt;  merge have1 have2;&lt;BR /&gt;  by county ;&lt;BR /&gt;run;</description>
      <pubDate>Thu, 12 Nov 2020 11:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-one-has-a-text-column-with-length-of-60/m-p/698360#M213573</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-11-12T11:59:31Z</dc:date>
    </item>
  </channel>
</rss>

