<?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 Avoid numeric conversion warning when using format INVALUE to recode in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Avoid-numeric-conversion-warning-when-using-format-INVALUE-to/m-p/935356#M367752</link>
    <description>&lt;P&gt;Hi SAS frens,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to use PROC FORMAT to recode Weight into an Injection Volume category but I get a NOTE (considered an Error by my company and will not pass validation) on the Numeric to Character conversion. How do I avoid this? I'd like to not use IF/THEN logic because my list is quite long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input id weight @;
 datalines;
1008 31.2
1009 47.8
1010 57.5
1011 95.5
1012 106.1
1013 110.0
1014 125.8
1015 166.3
 ;
run;

proc format;
 invalue vol3_ 
	 30.0 - 40.8  = 0.2
	 40.9 - 57.4  = 0.3
	 57.5 - 74.1  = 0.4
	 74.2 - 90.8  = 0.5
	 90.9 - 107.4 = 0.6
	107.5 - 124.1 = 0.7
	124.2 - 140.8 = 0.8
	140.9 - 157.4 = 0.9
	157.5 - 174.1 = 1.0
	174.2 - 180.0 = 1.1;
run;

data want;
	set have;
	inj_vol=input(weight, vol3_.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jul 2024 16:07:47 GMT</pubDate>
    <dc:creator>SAShole</dc:creator>
    <dc:date>2024-07-10T16:07:47Z</dc:date>
    <item>
      <title>Avoid numeric conversion warning when using format INVALUE to recode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Avoid-numeric-conversion-warning-when-using-format-INVALUE-to/m-p/935356#M367752</link>
      <description>&lt;P&gt;Hi SAS frens,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd like to use PROC FORMAT to recode Weight into an Injection Volume category but I get a NOTE (considered an Error by my company and will not pass validation) on the Numeric to Character conversion. How do I avoid this? I'd like to not use IF/THEN logic because my list is quite long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input id weight @;
 datalines;
1008 31.2
1009 47.8
1010 57.5
1011 95.5
1012 106.1
1013 110.0
1014 125.8
1015 166.3
 ;
run;

proc format;
 invalue vol3_ 
	 30.0 - 40.8  = 0.2
	 40.9 - 57.4  = 0.3
	 57.5 - 74.1  = 0.4
	 74.2 - 90.8  = 0.5
	 90.9 - 107.4 = 0.6
	107.5 - 124.1 = 0.7
	124.2 - 140.8 = 0.8
	140.9 - 157.4 = 0.9
	157.5 - 174.1 = 1.0
	174.2 - 180.0 = 1.1;
run;

data want;
	set have;
	inj_vol=input(weight, vol3_.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 16:07:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Avoid-numeric-conversion-warning-when-using-format-INVALUE-to/m-p/935356#M367752</guid>
      <dc:creator>SAShole</dc:creator>
      <dc:date>2024-07-10T16:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: Avoid numeric conversion warning when using format INVALUE to recode</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Avoid-numeric-conversion-warning-when-using-format-INVALUE-to/m-p/935357#M367753</link>
      <description>&lt;P&gt;INPUT function expect text values so control the conversion to text of your existing numeric value with the PUT function and an appropriate format.&lt;/P&gt;
&lt;P&gt;The -L option with the Put function left justifies the value so there are not leading spaces which might confuse your informat.&lt;/P&gt;
&lt;PRE&gt;data want;
	set have;
	inj_vol=input(put(weight,best8. -L), vol3_.);
run;&lt;/PRE&gt;
&lt;P&gt;OR create a Format and INPUT the formatted value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;inj_vol =  input (put(weight,yourvolfmt. -L),8.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want to be very cautious about ranges of character values, which the Informat actually stores for the start and end values. Note that your informat will treat a value like 40.8999999 as if it is 40.8 because of the rules for comparing character values.&lt;/P&gt;
&lt;P&gt;You may want to specify an OTHER option in the value ranges with the _error_ assignment to create notes in the log about unexpected values.&lt;/P&gt;
&lt;P&gt;Example, note the added row of data in the Have with the value of 3000.&lt;/P&gt;
&lt;PRE&gt;data have;
 input id weight @;
 datalines;
1008 31.2
1009 47.8
1010 57.5
1011 95.5
1012 106.1
1013 110.0
1014 125.8
1015 166.3
1016 3000
 ;
run;

proc format library=work cntlout=work.cntlout;
 invalue vol3_ 
	 30.0 - 40.8  = 0.2
	 40.9 - 57.4  = 0.3
	 57.5 - 74.1  = 0.4
	 74.2 - 90.8  = 0.5
	 90.9 - 107.4 = 0.6
	107.5 - 124.1 = 0.7
	124.2 - 140.8 = 0.8
	140.9 - 157.4 = 0.9
	157.5 - 174.1 = 1.0
	174.2 - 180.0 = 1.1
   other = _error_
   ;
run;

data want;
	set have;
	inj_vol=input(put(weight,best8. -L), vol3_.);
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 17:00:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Avoid-numeric-conversion-warning-when-using-format-INVALUE-to/m-p/935357#M367753</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-07-10T17:00:48Z</dc:date>
    </item>
  </channel>
</rss>

