<?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: Numeric to numeric format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842672#M333205</link>
    <description>&lt;P&gt;FORMATS convert values to text.&amp;nbsp; INFORMATS convert text to values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numeric formats convert numbers to text.&lt;/P&gt;
&lt;P&gt;Numeric informats convert text to numbers.&lt;/P&gt;
&lt;P&gt;Character formats AND character informats convert text to text.&lt;/P&gt;
&lt;P&gt;There is not number to number conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a different method.&amp;nbsp; Use both PUT() and INPUT().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_number = input(put(old_number,myformat.),32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use a look-up table.&amp;nbsp; You could use an INDEX.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  set lookup index=old_number;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or a hash object.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Nov 2022 14:57:06 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-11-05T14:57:06Z</dc:date>
    <item>
      <title>Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842659#M333200</link>
      <description>&lt;P&gt;Hello, I have a invalue format to populate the value of VISITNUM for some records where it's value is missing using AVISITN which is populated for all records as a reference. Both are numeric variables. So if AVISITN = 10 I would want the missing VISITNUM&amp;nbsp; to be 1 etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input VISITNUM :8. AVISITN :8.;
infile datalines dlm = '|';
datalines;
1|10|
2|20|
4|30|
5|40|
6|50|
7|60|
8|70|
1|10|
2|20|
4|30|
5|40|
6|50|
 |60|
 |70|
 |80|
1|10|
2|20|
4|30|
5|40|
 |50|
 |60|
 |70|
 |80|
1|10|
2|20|
 |30|
 |40|
 |50|
 |60|
 |70|
 |80|
;
RUN;

data want;
input VISITNUM :8. AVISITN :8.;
infile datalines dlm = '|';
datalines;
1|10|
2|20|
4|30|
5|40|
6|50|
7|60|
8|70|
1|10|
2|20|
4|30|
5|40|
6|50|
7|60|
8|70|
9|80|
1|10|
2|20|
4|30|
5|40|
6|50|
7|60|
8|70|
9|80|
1|10|
2|20|
4|30|
5|40|
6|50|
7|60|
8|70|
9|80|
 ;
RUN;&lt;/CODE&gt;&lt;/PRE&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;proc format;    
 
 invalue dummy_visnum
        10 = 1
        20 = 2        
        30 = 4
        40 = 5
        50 = 6
        60 = 7
        70 = 8
        80 = 9
        100= 10;
       

quit;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However when I run this code it works as intended but I get a warning in my log "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;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; visitnum = input(avisitn, dummy_visnum.); &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is the workaround to eliminate this?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 14:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842659#M333200</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-11-05T14:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842660#M333201</link>
      <description>&lt;P&gt;"The VALUE statement in PROC FORMAT is used to define a FORMAT. The INVALUE statement is used to define an INFORMAT. In &lt;SPAN class="df_rq   " data-entity-tipid="df_rq_tip_SAS"&gt;&lt;A href="https://www.bing.com/ck/a?!&amp;amp;&amp;amp;p=c330e5ca0e021ecfJmltdHM9MTY2NzYwNjQwMCZpZ3VpZD0xMjEzZGFmOS1mNjhmLTYwMWEtMjIyMC1jYmJkZjc3MjYxYjQmaW5zaWQ9NTQxOQ&amp;amp;ptn=3&amp;amp;hsh=3&amp;amp;fclid=1213daf9-f68f-601a-2220-cbbdf77261b4&amp;amp;u=a1L3NlYXJjaD9xPVNBUyZmaWx0ZXJzPXNpZCUzYTJiODk4MWRkLTczMjAtYTI3OS1hZGMxLWVlYTdhY2FhMWIxYSZmb3JtPUVOVExOSw&amp;amp;ntb=1" target="_blank" rel="noopener"&gt;SAS&lt;/A&gt;&lt;/SPAN&gt; you use a FORMAT to&lt;STRONG&gt; convert values into text and an INFORMAT to convert &lt;FONT color="#008000"&gt;text&lt;/FONT&gt; into values&lt;/STRONG&gt;."&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With INFORMAT, you are telling SAS that AVISITN Is &lt;FONT color="#339966"&gt;text&lt;/FONT&gt;, but it is actually a number. Hence, SAS converts AVISITN into text.&lt;/P&gt;
&lt;P&gt;Why not just divide by 10?:&lt;/P&gt;
&lt;P&gt;if missing(visitn) then visitn = avisitn / 10&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 13:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842660#M333201</guid>
      <dc:creator>pink_poodle</dc:creator>
      <dc:date>2022-11-05T13:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842664#M333202</link>
      <description>&lt;P&gt;Yeah I would do that normally but the data is slightly &lt;SPAN&gt;asynchronous&lt;/SPAN&gt; as it does not have a one to one conversion as visitnum = 3 is AVISITN = 40 and same for VISITNUM 4 to 9. It is only 1,2 and 10 where this would work . Yeah I can see that my approach doesn't work and I've tried other ways such as this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;visitnum = input(cats(mod(avisitn,10)),dummy_visnum.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I get values of 0 also for the same reason I presume&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 13:52:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842664#M333202</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-11-05T13:52:45Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842672#M333205</link>
      <description>&lt;P&gt;FORMATS convert values to text.&amp;nbsp; INFORMATS convert text to values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Numeric formats convert numbers to text.&lt;/P&gt;
&lt;P&gt;Numeric informats convert text to numbers.&lt;/P&gt;
&lt;P&gt;Character formats AND character informats convert text to text.&lt;/P&gt;
&lt;P&gt;There is not number to number conversion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use a different method.&amp;nbsp; Use both PUT() and INPUT().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_number = input(put(old_number,myformat.),32.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use a look-up table.&amp;nbsp; You could use an INDEX.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have ;
  set lookup index=old_number;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or a hash object.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 14:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842672#M333205</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-05T14:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842673#M333206</link>
      <description>&lt;P&gt;I was missing the 32. at the end!. Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 15:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842673#M333206</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-11-05T15:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842676#M333207</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430963"&gt;@smackerz1988&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yeah I would do that normally but the data is slightly &lt;SPAN&gt;asynchronous&lt;/SPAN&gt; as it does not have a one to one conversion as visitnum = 3 is AVISITN = 40 and same for VISITNUM 4 to 9. It is only 1,2 and 10 where this would work . Yeah I can see that my approach doesn't work and I've tried other ways such as this&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;visitnum = input(cats(mod(avisitn,10)),dummy_visnum.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I get values of 0 also for the same reason I presume&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Simple algebra seems to me to be the easiest way to get there, and with the least coding. An IF statement doing one thing when AVISITN if 40 or greater, and an ELSE statement to handle when AVISITN &amp;lt; 40.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 16:27:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842676#M333207</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-05T16:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Numeric to numeric format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842687#M333213</link>
      <description>&lt;P&gt;of course but it was more the approach to getting around the numeric to numeric format problem moreso than that. I knew it was a combination out put/input but was just missing the 32..&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2022 17:25:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Numeric-to-numeric-format/m-p/842687#M333213</guid>
      <dc:creator>smackerz1988</dc:creator>
      <dc:date>2022-11-05T17:25:07Z</dc:date>
    </item>
  </channel>
</rss>

