<?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 2 SAS datasets with same format name in 2 catalogs in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604581#M17114</link>
    <description>&lt;P&gt;Thank you so much for you assistance. It is very helpful.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2019 18:38:19 GMT</pubDate>
    <dc:creator>Thanyada</dc:creator>
    <dc:date>2019-11-15T18:38:19Z</dc:date>
    <item>
      <title>Merge 2 SAS datasets with same format name in 2 catalogs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604562#M17099</link>
      <description>&lt;P&gt;Some people gave me 2 SAS datasets and 2 SAS catalog files&lt;/P&gt;&lt;P&gt;I would like to merge those datasets&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the problem is each SAS catalog file containing the same name format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname data1 "&amp;lt;location&amp;gt;";&lt;/P&gt;&lt;P&gt;libname data2 "&amp;lt;location&amp;gt;";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options fmtsearch = (data1 data2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = data1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by V1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = data2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by V1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data temp1;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; merge data1.dataset1 data2.dataset2;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by V1;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I deal with the same format names in 2 SAS catalog files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 17:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604562#M17099</guid>
      <dc:creator>Thanyada</dc:creator>
      <dc:date>2019-11-15T17:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Merge 2 SAS datasets with same format name in 2 catalogs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604564#M17100</link>
      <description>&lt;P&gt;Are the formats in fact different?&amp;nbsp; Or are they just copies of the same format?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 17:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604564#M17100</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T17:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Merge 2 SAS datasets with same format name in 2 catalogs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604565#M17101</link>
      <description>&lt;P&gt;The formats are different&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 17:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604565#M17101</guid>
      <dc:creator>Thanyada</dc:creator>
      <dc:date>2019-11-15T17:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Merge 2 SAS datasets with same format name in 2 catalogs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604569#M17105</link>
      <description>&lt;P&gt;So you need to change the name of one of them.&amp;nbsp; Probably best to not mess with the original and instead make a new catalog.&lt;/P&gt;
&lt;P&gt;Let's make two format catalogs that both have the same format name in them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format lib=work.formatsA;
value x 1='Version A';
run;
proc format lib=work.formatsB;
value x 1='Version B';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now we can use PROC CATALOG to copy those into a new catalog and rename them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc catalog cat=work.formats_all;
  copy in=work.formatsA out=work.formats_all;
   select x /et=format;
  run;
  change x=xA (et=format);
  run;
  copy in=work.formatsB out=work.formats_all;
   select x /et=format;
  run;
  change x=xb (et=format);
  run;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the entry type of character formats is FORMATC instead of FORMAT.&amp;nbsp; Also remember that format names cannot end in a digit.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now you need to change the format attached the variables to match the new names.&lt;/P&gt;
&lt;P&gt;So let's assume that the variables A in DATASET1 and B in DATASET2 are both using the format X.&amp;nbsp; So just add a FORMAT statement to the data step that merges them to attach the renamed formats instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp1;  
  merge data1.dataset1 data2.dataset2;
  by V1;
  format A XA.  B XB. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the variable names are the same (In addition to the format names that are attached to them) then you probably need to rename one or both of the variables.&amp;nbsp; &amp;nbsp;For example if the variable is named X in both datasets you probably want something like this instead.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp1;  
  merge data1.dataset1(rename=(X=XA))
        data2.dataset2(rename=(X=XB))
  ;
  by V1;
  format XA XA.  XB XB. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:12:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604569#M17105</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T18:12:43Z</dc:date>
    </item>
    <item>
      <title>Re: Merge 2 SAS datasets with same format name in 2 catalogs</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604581#M17114</link>
      <description>&lt;P&gt;Thank you so much for you assistance. It is very helpful.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge-2-SAS-datasets-with-same-format-name-in-2-catalogs/m-p/604581#M17114</guid>
      <dc:creator>Thanyada</dc:creator>
      <dc:date>2019-11-15T18:38:19Z</dc:date>
    </item>
  </channel>
</rss>

