<?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: Fun with Formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560271#M156631</link>
    <description>&lt;P&gt;Use&lt;/P&gt;
&lt;PRE&gt;data ctrl;
   length label $ 11;
   set format_in(rename=(begin=start amount=label)) end=last;
   retain fmtname 'test_format' type '&lt;FONT color="#800080"&gt;&lt;STRONG&gt;N&lt;/STRONG&gt;&lt;/FONT&gt;';
   output;
   if last then do;
      hlo='O';
      label='***ERROR***';
      output;
   end;
run;

&lt;/PRE&gt;
&lt;P&gt;The PUT function is what creates the character value, not the type of the format.&lt;/P&gt;</description>
    <pubDate>Mon, 20 May 2019 20:04:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-05-20T20:04:02Z</dc:date>
    <item>
      <title>Fun with Formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560229#M156602</link>
      <description>&lt;P&gt;I am trying to create and use a user-defined format to convert a numeric value to a character value.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my test code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data format_in;
   input begin $ 1-3 end $ 5-8 amount $ 10-12;
   datalines;
1   1    RG
2   2    RG
3   3    RB
4   4    RB
5   5    RS
;
data ctrl;
   length label $ 11;
   set format_in(rename=(begin=start amount=label)) end=last;
   retain fmtname 'test_format' type 'C';
   output;
   if last then do;
      hlo='O';
      label='***ERROR***';
      output;
   end;
run;


proc format library=work cntlin=ctrl;
run;

proc sql; create table test
(Tier num(1));
insert into test
values(1)
values(2)
values(3)
values(4)
values(5);
run;

data test2;
set test;
Util=put(tier,$test_format.);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this returns the following errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;70         data test2;

71         set test;
72         Util=put(tier,$test_format.);
                         _____________
                         484
WARNING: Variable Tier has already been defined as numeric.
NOTE 484-185: Format TEST_FORMAT was not found or could not be loaded.&lt;/PRE&gt;&lt;P&gt;Does anyone know what is going on? I am not sure why the format can't be loaded or found when I just created it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 17:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560229#M156602</guid>
      <dc:creator>theponcer</dc:creator>
      <dc:date>2019-05-20T17:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: Fun with Formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560233#M156606</link>
      <description>&lt;P&gt;Try this change&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;retain fmtname 'test_format' type 'N';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;followed by&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Util=put(tier,test_format.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 17:31:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560233#M156606</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-05-20T17:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fun with Formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560237#M156610</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/252152"&gt;@theponcer&lt;/a&gt;&amp;nbsp;wrote:
&lt;PRE&gt;70         data test2;

71         set test;
72         Util=put(tier,$test_format.);
                         _____________
                         484
WARNING: Variable Tier has already been defined as numeric.
NOTE 484-185: Format TEST_FORMAT was not found or could not be loaded.&lt;/PRE&gt;
&lt;P&gt;Does anyone know what is going on? I am not sure why the format can't be loaded or found when I just created it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A character format cannot be applied to a numeric variable, hence the warning. Having noticed that &lt;FONT face="courier new,courier"&gt;tier&lt;/FONT&gt; is a numeric variable, SAS searches for a &lt;EM&gt;numeric&lt;/EM&gt; format with the specified name, but ignoring the dollar sign. The search is unsuccessful in this case, hence the note (which does &lt;EM&gt;not&lt;/EM&gt; state that format &lt;STRONG&gt;$&lt;/STRONG&gt;TEST_FORMAT was not found).&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 17:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560237#M156610</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-20T17:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Fun with Formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560271#M156631</link>
      <description>&lt;P&gt;Use&lt;/P&gt;
&lt;PRE&gt;data ctrl;
   length label $ 11;
   set format_in(rename=(begin=start amount=label)) end=last;
   retain fmtname 'test_format' type '&lt;FONT color="#800080"&gt;&lt;STRONG&gt;N&lt;/STRONG&gt;&lt;/FONT&gt;';
   output;
   if last then do;
      hlo='O';
      label='***ERROR***';
      output;
   end;
run;

&lt;/PRE&gt;
&lt;P&gt;The PUT function is what creates the character value, not the type of the format.&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 20:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560271#M156631</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-20T20:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fun with Formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560274#M156633</link>
      <description>&lt;P&gt;Thanks - this clears up my confusion!&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 20:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fun-with-Formats/m-p/560274#M156633</guid>
      <dc:creator>theponcer</dc:creator>
      <dc:date>2019-05-20T20:12:49Z</dc:date>
    </item>
  </channel>
</rss>

