<?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: Conditional Formatting using proc format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600374#M173527</link>
    <description>&lt;P&gt;Thanks Tom - that solved my issue.&amp;nbsp; I still feel like I remember that there is a way, in the proc format itself, to apply the conditions based on the value of the variable being formatted.&amp;nbsp; But, it was a long time ago!&lt;/P&gt;</description>
    <pubDate>Wed, 30 Oct 2019 13:35:33 GMT</pubDate>
    <dc:creator>jbatch</dc:creator>
    <dc:date>2019-10-30T13:35:33Z</dc:date>
    <item>
      <title>Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600161#M173404</link>
      <description>&lt;P&gt;I have looked at a number of conditional formatting questions, but none seem to quite get what I'm after.&amp;nbsp; I'm frustrated, because I believe I went to a conference where someone talked about using proc format but being able to apply it conditionally, and I think I've successfully done it in the past but can't find a program using that method.&amp;nbsp; I would also be willing to use proc report, but it's newish to me!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I'm trying to do is apply a format to var2 based on the value of var1.&amp;nbsp; So if var1 is 'food' then var2 should be 'broccoli'.&amp;nbsp; If var1 is 'auto' then var2 should be 'sedan'.&amp;nbsp; Obvious oversimplification, but that's what I'm trying to do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 19:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600161#M173404</guid>
      <dc:creator>jbatch</dc:creator>
      <dc:date>2019-10-29T19:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600168#M173406</link>
      <description>&lt;P&gt;It seems that you are looking for a format similar to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format lib=work; /* or any other library */
      value $new
      'food' = 'broccoli'
      'auto' = 'sedan''
     ...
  ; run;

data want;
  set have;
       length var2 $20;
       var2 = put(var1, $new.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 20:11:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600168#M173406</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2019-10-29T20:11:53Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600172#M173407</link>
      <description>Maybe you're looking for PUTC()? Hard to understand, it would help if you could provide an example.</description>
      <pubDate>Tue, 29 Oct 2019 20:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600172#M173407</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-10-29T20:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600183#M173412</link>
      <description>&lt;P&gt;You cannot change the format attached to a variable. You can decided which format to use using logic however.&lt;/P&gt;
&lt;P&gt;Let's say you have two formats named FOOD and AUTO that convert numbers into names of food or car types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you use the different formats to decode the numbers into a character variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length result $20;
if var1='food' then result=put(var2,food20.);
else if var1='auto' then result=put(var2,auto20.);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could even use the PUTN() function to simplify the code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;result=putn(var2,cats(var1,'20.'));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 21:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600183#M173412</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-29T21:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600325#M173496</link>
      <description>&lt;P&gt;If your first variable, VAR1, is a nice SAS-compatible name, you can use the variable value as a format name, and then use PUTC or PUTN (depending on the type of VAR2), e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input var1 $ var2;
cards;
auto 1
food 1
;run;

proc format;
  value auto 1='sedan'
  ;
  value food 1='broccoli';
  ;
run;

data want;
  set have;
  formatted_value=putn(var2,cats(var1,'20.'));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 10:53:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600325#M173496</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-10-30T10:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600374#M173527</link>
      <description>&lt;P&gt;Thanks Tom - that solved my issue.&amp;nbsp; I still feel like I remember that there is a way, in the proc format itself, to apply the conditions based on the value of the variable being formatted.&amp;nbsp; But, it was a long time ago!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Oct 2019 13:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600374#M173527</guid>
      <dc:creator>jbatch</dc:creator>
      <dc:date>2019-10-30T13:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional Formatting using proc format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600405#M173546</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/220"&gt;@jbatch&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Tom - that solved my issue.&amp;nbsp; I still feel like I remember that there is a way, in the proc format itself, to apply the conditions based on the value of the variable being formatted.&amp;nbsp; But, it was a long time ago!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is only possible if the range of values do not overlap.&amp;nbsp; So if 1-10 is used for food and 100-200 is use for autos you could make a format like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value combo
 1-10=[food.]
 100-200=[auto.]
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Oct 2019 14:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditional-Formatting-using-proc-format/m-p/600405#M173546</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-10-30T14:17:03Z</dc:date>
    </item>
  </channel>
</rss>

