<?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: F2. format creating the character '.' for missing Numeric values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884911#M349607</link>
    <description>&lt;P&gt;Thank you for explaining the 'IFN' and IFC. and you are correct.&lt;/P&gt;</description>
    <pubDate>Sat, 15 Jul 2023 16:34:29 GMT</pubDate>
    <dc:creator>SASuserlot</dc:creator>
    <dc:date>2023-07-15T16:34:29Z</dc:date>
    <item>
      <title>F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884901#M349600</link>
      <description>&lt;P&gt;I have the following scenario, How do we get the character blank value when we have the missing numeric value? Why it's not working&amp;gt; Thanks for your input. I want avalc = '' when aval is missing.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; data dd;
 input aval;
 cards;
 2
 .
 ; 
run;

data ddx;
set dd;
AVALC   =  ifn (aval =.,'',left(put(aval, f2.)));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Jul 2023 06:51:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884901#M349600</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-07-15T06:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884902#M349601</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/350312"&gt;@SASuserlot&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a case for &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_blank" rel="noopener"&gt;Maxim 2&lt;/A&gt;, "Read the log."&lt;/P&gt;
&lt;PRE&gt;9     data ddx;
10    set dd;
11    AVALC   =  ifn (aval =.,'',left(put(aval, f2.)));
12    run;

&lt;FONT color="#3366FF"&gt;NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
      11:25   11:28
NOTE: There were 2 observations read from the data set WORK.DD.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Why did SAS convert a character value to numeric in each of the two observations? Because the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n0l3n5z2h31h7wn1fmnqd33ibhap.htm" target="_blank" rel="noopener"&gt;IFN function&lt;/A&gt; returns a &lt;EM&gt;numeric&lt;/EM&gt; result (which also makes AVALC a numeric variable as it hadn't been defined as character). So, switch to the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p07za51a2k0sxkn1m0tulx2cy464.htm" target="_blank" rel="noopener"&gt;IFC function&lt;/A&gt;, read the log again&lt;/P&gt;
&lt;PRE&gt;14    data ddx;
15    set dd;
16    AVALC   =  ifc (aval =.,'',left(put(aval, f2.)));
17    run;

INFO: Character variables have defaulted to a length of 200 at the places given by: (Line):(Column). Truncation can result.
      16:1     AVALC
&lt;FONT color="#3366FF"&gt;NOTE: There were 2 observations read from the data set WORK.DD.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;(hopefully, you are using &lt;FONT face="courier new,courier"&gt;options msglevel=I&lt;/FONT&gt;, otherwise you wouldn't get the important INFO)&lt;/P&gt;
&lt;P&gt;and thus remember to insert the LENGTH statement before the assignment statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length AVALC $2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;Hint:&amp;nbsp;&lt;FONT face="courier new,courier"&gt;left(put(aval, f2.))&lt;/FONT&gt; could be replaced by&amp;nbsp;&lt;FONT face="courier new,courier"&gt;put(aval, 2.-l)&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 08:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884902#M349601</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2023-07-15T08:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884903#M349602</link>
      <description>&lt;P&gt;If all you want to do is change the APPEARANCE of a value, this is what formats do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_self"&gt;Maxim 8&lt;/A&gt; "SAS provides a plethora of formats for input and output. Use them to your advantage. If one that fits your needs is not present, rolling your own will usually beat complicated data step logic.")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format; 
    value missf .=' '; 
run;

data dd;
    input aval;
    format aval missf.;
    cards;
 2
 .
 ; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the special case of changing the appearance of a missing, its even simpler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options missing=' ';

data dd;
    input aval;
    cards;
2
.
; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 09:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884903#M349602</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-07-15T09:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884905#M349603</link>
      <description>&lt;P&gt;&lt;STRONG&gt;In your code, use "AVALC = ifn(aval = ., '', left(put(aval, f2.)));", it will assign a blank value when aval is missing.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 12:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884905#M349603</guid>
      <dc:creator>SethHunt</dc:creator>
      <dc:date>2023-07-15T12:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884906#M349604</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/446029"&gt;@SethHunt&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;STRONG&gt;In your code, use "AVALC = ifn(aval = ., '', left(put(aval, f2.)));", it will assign a blank value when aval is missing.&lt;/STRONG&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No, it won't. By using IFN instead of IFC, you create a missing&amp;nbsp;&lt;EM&gt;numeric&lt;/EM&gt; value, which is always displayed as a dot (unless specified otherwise with the MISSING system option).&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 14:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884906#M349604</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-07-15T14:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884907#M349605</link>
      <description>&lt;P&gt;Thank you, Not sure how I missed that log Note. It worked. Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 16:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884907#M349605</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-07-15T16:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884911#M349607</link>
      <description>&lt;P&gt;Thank you for explaining the 'IFN' and IFC. and you are correct.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 16:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884911#M349607</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-07-15T16:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884912#M349608</link>
      <description>&lt;P&gt;I gave the 'missing' option at the top, but not sure why it didn't work in my case( In my actual code, not the example here). But thanks for explaining how I can use formats in this scenario.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have one question. This was the code written by an experienced guy ( retired in Data science) . I want to understand the result of the code in the following scenario.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scenario:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;'AVAL' is a numeric variable:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;AVALC = left(put(aval, f2.));&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. What happens to AVALC if AVAL is&amp;nbsp; missing&amp;nbsp; and I given the 'MISSING' system option.&lt;/P&gt;
&lt;P&gt;2.What happens to AVALC if AVAL is&amp;nbsp; missing&amp;nbsp; and I&amp;nbsp; &lt;STRONG&gt;Don't&lt;/STRONG&gt; given the 'MISSING' system option.&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp;What happens to AVALC if AVAL is&amp;nbsp; displaying as '&lt;STRONG&gt;.&lt;/STRONG&gt;'&lt;/P&gt;
&lt;P&gt;thank you for your time.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 16:41:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884912#M349608</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-07-15T16:41:52Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884913#M349609</link>
      <description>&lt;P&gt;As others have explained you are using the wrong function for creating a character value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why use those confusing IFN/IFC functions any way when you can just use normal basic SAS code?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ddx;
  set dd;
  if not missing(aval) then AVALC = put(aval,f2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or perhaps since F2. can only display values between -9 and 99 perhaps use:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ddx;
  set dd;
  if -9 &amp;lt;= aval &amp;lt;= 99 then AVALC = put(aval,f2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Jul 2023 17:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884913#M349609</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-15T17:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: F2. format creating the character '.' for missing Numeric values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884914#M349610</link>
      <description>&lt;P&gt;Thank you, Tom. This code was written by an experienced guy ( who retired). So I am handling his code.&amp;nbsp; unfortunately, What happening is the code he wrote creating a '.' in AVALC ( character variable). Which leads to the derivation of new useless records with '.', I am just trying to avoid. and I am new to IFN and IFC. I am learning it through trial and error. Thank you for giving the alternatives. I really appreciate your time.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Jul 2023 17:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/F2-format-creating-the-character-for-missing-Numeric-values/m-p/884914#M349610</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2023-07-15T17:26:08Z</dc:date>
    </item>
  </channel>
</rss>

