<?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: one format question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863116#M340963</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  do i=1 to 10;
    output;
  end;
run;

proc format;
  value num
    1-5  = 1
    6-10 = 2
    ;
run;

data x2;
  set x;
  x=input(put(i, num.),best32.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Mar 2023 02:54:39 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2023-03-09T02:54:39Z</dc:date>
    <item>
      <title>one format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863094#M340953</link>
      <description>&lt;P&gt;I want to regroup numeric variable as another numeric variable, and the log produce log like below. How can I update my code to remove the NOTE.&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
do i=1 to 10;
	output;
end;
run;
proc format ;
	value num
		1-5 =1
		6-10 =2;
run;
data x2;
	set x;
	x=input(i, num.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 23:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863094#M340953</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2023-03-08T23:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: one format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863110#M340959</link>
      <description>&lt;P&gt;Describe what you are actually wanting to do in a bit more detail.&lt;/P&gt;
&lt;P&gt;Your last data set actually gives more than the message you quoted:&lt;/P&gt;
&lt;PRE&gt;17   data x2;
18      set x;
19      x=input(i, num.);
                   ----
                   485
NOTE 485-185: Informat NUM was not found or could not be loaded.

20   run;

NOTE: Numeric values have been converted to character values at the places given by:
      (Line):(Column).
      19:12
&lt;/PRE&gt;
&lt;P&gt;The INPUT function requires an informat which would be created in Proc format with and invalue statement. It also expects a text value for input, which is why it converted i to character and generated that message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to use the format to create a group use something that wants a group. You don't need to modify the value.&lt;/P&gt;
&lt;P&gt;Consider:&lt;/P&gt;
&lt;PRE&gt;proc freq data=x;
   tables i;
   format i num.;
run;&lt;/PRE&gt;
&lt;P&gt;Typically conversion of numeric to numeric would use different logic depending on how complex the conversion might be.&lt;/P&gt;
&lt;P&gt;One way as an example to look for values in a list of integers:&lt;/P&gt;
&lt;PRE&gt;data x3;
	set x;
	If i in (1:5) then x=1;
   else if i in (6:10) then x=2;
run;&lt;/PRE&gt;
&lt;P&gt;If your rules are complex enough to actually warrant an input then you use an INFORMAT like this:&lt;/P&gt;
&lt;PRE&gt;Proc format;
invalue num
'1','2','3','4','5'=1
'6','7','8','9','10'=2
;

data x4;
  set x;
  x = input(put(i,best. -L),num.);
run;&lt;/PRE&gt;
&lt;P&gt;The above uses an explicit PUT to control how the numeric value I is converted to character for use with the informat in the Input function. Note that the -L is to left justify the conversion to text for the number because the Invalue definition does not include any leading spaces which would then not get the expected result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 02:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863110#M340959</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-09T02:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: one format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863116#M340963</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
  do i=1 to 10;
    output;
  end;
run;

proc format;
  value num
    1-5  = 1
    6-10 = 2
    ;
run;

data x2;
  set x;
  x=input(put(i, num.),best32.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Mar 2023 02:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863116#M340963</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-03-09T02:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: one format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863122#M340966</link>
      <description>&lt;P&gt;You can eliminate that note by not using a number in a place where a string is required.&lt;/P&gt;
&lt;P&gt;Formats convert values to text.&amp;nbsp; Informats convert text to values.&lt;/P&gt;
&lt;P&gt;Numeric formats convert numbers to text. Numeric informats convert text to numbers.&lt;/P&gt;
&lt;P&gt;Neither can convert numbers to numbers.&lt;/P&gt;
&lt;P&gt;To convert numbers to numbers you need to either use a FUNCTION.&amp;nbsp; Or use a combination of a FORMAT and an INFORMAT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you have this format (although for some reason you left out the quotes around the strings)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value num
  1-5='1'
  6-10='2'
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So to use it to convert the number 5 to the number 1 you would need to do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;x=input(put(5, num.),32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 03:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863122#M340966</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-09T03:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: one format question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863176#M340987</link>
      <description>&lt;P&gt;Thanks everyone for help. At beginning, I thought input can regroup numeric variable to new numeric variable. Looks like I need to refresh myself with some basic functions.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 13:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/one-format-question/m-p/863176#M340987</guid>
      <dc:creator>Niugg2010</dc:creator>
      <dc:date>2023-03-09T13:23:27Z</dc:date>
    </item>
  </channel>
</rss>

