<?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: Adding SAS format to existing catalog in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341675#M78231</link>
    <description>&lt;P&gt;If you want to add a format to a specific catalog then reference it the LIBRARY option in Proc Format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work.myformat;
value y
1 = '10'
other= 'something else';
;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the catalog does not exist the code will create the catalob myformat in the work library.&lt;/P&gt;
&lt;P&gt;If the format Y does&amp;nbsp;not exist in the catalog myformat in the Work library it will be added to the catalog.&lt;/P&gt;
&lt;P&gt;If the format Y&amp;nbsp;does exist in the catalog myformat in the Work library then, assuming no error, the new format Y replaces the old one.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2017 16:57:07 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-03-16T16:57:07Z</dc:date>
    <item>
      <title>Adding SAS format to existing catalog</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341634#M78219</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm working on a program where I want to add a format to existing format catalog i.e. I see a format catalog myformats.sas7bcat but I dont know which program creates that catalog. As most of the programs in my project already use that catalog using fmtsearch option, I want to add my new format to the same catalog.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341634#M78219</guid>
      <dc:creator>Neeta</dc:creator>
      <dc:date>2017-03-16T15:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding SAS format to existing catalog</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341645#M78223</link>
      <description>&lt;P&gt;So, you don't know where that is created, and that format catalog is used by other things. &amp;nbsp;Are you sure you want to be updating it? &amp;nbsp;I would really advise to find out more about what creates that, where, etc. as overwriting it may cause problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 15:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341645#M78223</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-03-16T15:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: Adding SAS format to existing catalog</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341675#M78231</link>
      <description>&lt;P&gt;If you want to add a format to a specific catalog then reference it the LIBRARY option in Proc Format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format library=work.myformat;
value y
1 = '10'
other= 'something else';
;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the catalog does not exist the code will create the catalob myformat in the work library.&lt;/P&gt;
&lt;P&gt;If the format Y does&amp;nbsp;not exist in the catalog myformat in the Work library it will be added to the catalog.&lt;/P&gt;
&lt;P&gt;If the format Y&amp;nbsp;does exist in the catalog myformat in the Work library then, assuming no error, the new format Y replaces the old one.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 16:57:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341675#M78231</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-16T16:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding SAS format to existing catalog</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341696#M78237</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2017 17:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341696#M78237</guid>
      <dc:creator>Neeta</dc:creator>
      <dc:date>2017-03-16T17:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Adding SAS format to existing catalog</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341698#M78239</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Copying individual prebuilt formats from one format catalog to another +goodies

inspired by
https://goo.gl/N24fhV
https://communities.sas.com/t5/Base-SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341634


HAVE ( Two prebuilt formats in separate catalogs)
==================================================

   Contents of Catalog WORK.CAT1ST

#    Name         Type
--------------------------
1    CAT1STFMT    FORMATC


   Contents of Catalog WORK.CAT2ND

#    Name         Type
---------------------------
1    CAT2NDFMT    INFMT



WANT  (both formats in catalog cat2nd)
======================================

  Contents of Catalog WORK.CAT2ND

#    Name         Type
---------------------------
1    CAT1STFMT    FORMATC
2    CAT2NDFMT    INFMT


WORKING CODE
===========

copy in=work.cat1st out=work.cat2nd ;
select cat1stfmt/entrytype=formatc;

FULL SOLUTION
=============

* just in case the catalogs exist then delete them;
proc datasets library=work memtype=(catalog);
delete cat1st / memtype=catalog;
delete cat2nd / memtype=catalog;
run;

* create three catalogs and combine them;
proc format library=work.cat1st;
  value $cat1stfmt
  'F' = 'Female'
  'M' = 'Male';
run;quit;

proc format library=work.cat2nd;
  invalue cat2ndfmt
  'F' = 1
  'M' = 2;
run;quit;

*Copy cat1stfmt to catalog cat2nd;
proc catalog ;
   copy in=work.cat1st out=work.cat2nd ;
   select cat1stfmt/entrytype=formatc;
run;quit;

*                      _ _
  __ _  ___   ___   __| (_) ___  ___
 / _` |/ _ \ / _ \ / _` | |/ _ \/ __|
| (_| | (_) | (_) | (_| | |  __/\__ \
 \__, |\___/ \___/ \__,_|_|\___||___/
 |___/
;

* add discriptions;
proc catalog cat=work.cat2nd;
  modify cat1stfmt.formatc (
    description="m-&amp;gt;male f-&amp;gt;female");
  modify cat2ndfmt.infmt (
    description="m-&amp;gt;2 f-&amp;gt;1");
run;quit;

/*
NOTE: Copying entry CAT1STFMT.FORMATC from catalog WORK.CAT1ST to catalog WORK.CAT2ND.
*/

* verify descriptions;
proc catalog cat=work.cat2nd;
contents;
run;quit;

/*
#    Name         Type     Description
--------------------------------------------
1    CAT1STFMT    FORMATC  m-&amp;gt;male f-&amp;gt;female
2    CAT2NDFMT    INFMT    m-&amp;gt;2 f-&amp;gt;1
*/


* liat all formats;
proc format fmtlib library=work.formats;
run;quit;

/* delete individual format entries */
proc catalog catalog=work.formats;
delete win2unx.formatc;
delete win2unx.format;
delete win2unx.infmt;
run;quit;

/* delete catalogs */
proc datasets library=work memtype=(catalog);
delete cat1st / memtype=catalog;
delete cat2nd / memtype=catalog;
delete cat3rd / memtype=catalog;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Mar 2017 18:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-SAS-format-to-existing-catalog/m-p/341698#M78239</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-03-16T18:00:39Z</dc:date>
    </item>
  </channel>
</rss>

