<?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: Modify a value label in memory in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753115#M237324</link>
    <description>&lt;P&gt;The programming to do this is not simple, but is relatively short.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using a permanently saved format, you need to now the name of both the format itself (easy) and the format catalog holding the format (not as easy).&amp;nbsp; Then it would take three steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Download the contents of the format into a SAS data set.&amp;nbsp; This means using PROC FORMAT with the CNTLOUT= option.&lt;/LI&gt;
&lt;LI&gt;Modify that downloaded SAS data set (see code below).&lt;/LI&gt;
&lt;LI&gt;Re-generate the format using the modified SAS data set.&amp;nbsp; This means using PROC FORMAT with the CNTLIN= option.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Sample code to modify the SAS data set that was downloaded from the format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data modified_version;
   set downloaded_format end=done;
   output;
   if done;
   start = /* new value being defined in the format */;
   end = /* same new value being defined in the format */;
   label = /* label you want to assign to that new value */;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take a look and see if this seems like a viable approach for you.&amp;nbsp; THere are definitely a few complex details, but perhaps only a dozen lines of programming.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 11:51:29 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2021-07-09T11:51:29Z</dc:date>
    <item>
      <title>Modify a value label in memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753093#M237315</link>
      <description>&lt;P&gt;Dear SAS experts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have in my dataset a value label (value label: a term I know from working with Stata for many years) created using proc format; value specification. It is intended for a variable which contains thousands of data points and therefore the value label includes specification of MANY values. However, I would very much like to add just one more value label (a label for .).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to simply modify the existing value label such that it includes one more value label, while maintaining the existing value labels?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working in a system where I can simply upload the format and thereby apply the value label directly, i.e. I don't actually have to specify the value label using proc format; value.. This saves me MANY lines of code. I can upload the full code into my program file and thereby simply add the additional value label (i.e. add an additional line of code), but I would much rather simply modify the existing format and - if possible - save many lines of code.&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;Best regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 09:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753093#M237315</guid>
      <dc:creator>mgrasmussen</dc:creator>
      <dc:date>2021-07-09T09:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a value label in memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753098#M237316</link>
      <description>&lt;P&gt;To modify a format to add a condition when the original data is missing, you have to change the VALUE statement in PROC FORMAT that created the format. Then you have to run this changed PROC FORMAT.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 10:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753098#M237316</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-07-09T10:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a value label in memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753115#M237324</link>
      <description>&lt;P&gt;The programming to do this is not simple, but is relatively short.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are using a permanently saved format, you need to now the name of both the format itself (easy) and the format catalog holding the format (not as easy).&amp;nbsp; Then it would take three steps:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Download the contents of the format into a SAS data set.&amp;nbsp; This means using PROC FORMAT with the CNTLOUT= option.&lt;/LI&gt;
&lt;LI&gt;Modify that downloaded SAS data set (see code below).&lt;/LI&gt;
&lt;LI&gt;Re-generate the format using the modified SAS data set.&amp;nbsp; This means using PROC FORMAT with the CNTLIN= option.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Sample code to modify the SAS data set that was downloaded from the format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data modified_version;
   set downloaded_format end=done;
   output;
   if done;
   start = /* new value being defined in the format */;
   end = /* same new value being defined in the format */;
   label = /* label you want to assign to that new value */;
   output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Take a look and see if this seems like a viable approach for you.&amp;nbsp; THere are definitely a few complex details, but perhaps only a dozen lines of programming.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 11:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753115#M237324</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2021-07-09T11:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a value label in memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753118#M237326</link>
      <description>&lt;P&gt;You can always use %include to copy the code of an existing SAS program into your current code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you can keep the definition of a format in a separate file and use this wherever you need it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really want to add another "line" to an existing format checkout the code sample below. This will overwrite the existing format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*
 * original format
 */
proc format;
  value myfmt
    11 = "eleven"
    12 = "twelve"
    13 = "thirteen"
  ;
run;

/*
 * use it
 */
proc print data=sashelp.class;
  format age myfmt.;
run;

/*
 * write out definition
 */
proc format cntlout=fmtdef;
  select myfmt;
run;

/*
 * insert additional "line"
 */
proc sql;
  insert into fmtdef
    set
      fmtname = "myfmt"
      , type = "n"
      , start = "14"
      , end = "14"
      , label = "fourteen"
  ;
quit;

/*
 * recreate it
 */
proc format cntlin=fmtdef;
run;

/*
 * check it out
 */
proc print data=sashelp.class;
  format age myfmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jul 2021 12:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753118#M237326</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2021-07-09T12:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: Modify a value label in memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753120#M237328</link>
      <description>&lt;P&gt;What do you want display missing values as?&amp;nbsp; If it is just a single letter try just changing the MISSING system option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not define a new format that references the old format and overrides the decode used for missing values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value newfmt
  . = 'New decode'
  other = [oldfmt.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use the new format with your variable(s).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
  format varname newfmt.;
  tables varname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Otherwise please explain more clearly what you are doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have SAS code that defined the format changing the way it displays missing values should be a simple one line change to the code.&lt;/P&gt;
&lt;P&gt;If you have a SAS dataset you are using with CNTLIN= option of PROC FORMAT to define the format then a simple one line change to the dataset is all you will need.&amp;nbsp; Make sure you understand how to use the HLO variable in the control dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 12:10:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Modify-a-value-label-in-memory/m-p/753120#M237328</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-07-09T12:10:59Z</dc:date>
    </item>
  </channel>
</rss>

