<?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: How to fix Invalid numeric data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818872#M323251</link>
    <description>Thank you. My raw datasets contains many observations . My pgm consist of the category of the last weight for each obs.&lt;BR /&gt;&lt;BR /&gt;**Report the last weight and remove all missing data&lt;BR /&gt;DATA LASTWEIGHT;&lt;BR /&gt;SET DMWEIGHT;&lt;BR /&gt;WHERE WEIGHT IS NOT MISSING;&lt;BR /&gt;BY ID;&lt;BR /&gt;IF LAST.ID;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;*Split the weight to report the the weight category&lt;BR /&gt;DATA WGHTLAST(KEEP=ID VISIT WEIGHT WGHTCAT);&lt;BR /&gt;SET LASTWEIGHT;&lt;BR /&gt;LENGTH WGHTCAT $20;&lt;BR /&gt;IF WEIGHT &amp;lt;50.0 THEN WGHTCAT='&amp;lt;50 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;50.0 and WEIGHT&amp;lt;60.0 THEN WGHTCAT='50-60 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;60.0 and WEIGHT&amp;lt;70.0 THEN WGHTCAT='60-70 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;70.0 and WEIGHT&amp;lt;80.0 THEN WGHTCAT='70-80 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;80.0 and WEIGHT&amp;lt;90.0 THEN WGHTCAT='80-90 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;90.0 and WEIGHT&amp;lt;100.0 THEN WGHTCAT='90-100Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;100.0 and WEIGHT&amp;lt;110.0 THEN WGHTCAT='100 – 110 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;110.0 and WEIGHT&amp;lt;120.0 THEN WGHTCAT='110 – 120 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;120.0 THEN WGHTCAT='&amp;gt;=120Kg';&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;'D' means Not Done . I think I have to remove it but the issue is that user can enter the number both with comma and dot .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 17 Jun 2022 17:18:45 GMT</pubDate>
    <dc:creator>ndamo</dc:creator>
    <dc:date>2022-06-17T17:18:45Z</dc:date>
    <item>
      <title>How to fix Invalid numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818816#M323228</link>
      <description>&lt;P&gt;Dear Community ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on the data to report the category of numeric variable( Weight ).&amp;nbsp;&lt;/P&gt;&lt;P&gt;my dataset looks like below:&lt;BR /&gt;ID Weight&amp;nbsp; &amp;nbsp; Wtcat&lt;BR /&gt;1 50&amp;nbsp;&lt;BR /&gt;2 60&lt;BR /&gt;3 80&lt;BR /&gt;4 60,75&amp;nbsp;&amp;nbsp;&lt;BR /&gt;5 75&lt;BR /&gt;6 D&lt;/P&gt;&lt;P&gt;Wtcat is the new column to report the categories of weight e.g &amp;lt;50= cat1 , 50-60= cat2 etc.....)&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my pgm:&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA new;&lt;BR /&gt;SET old;&lt;BR /&gt;LENGTH Wtcat $20;&lt;BR /&gt;IF WEIGHT &amp;lt;50.0 THEN Wtcat ='&amp;lt;50 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;50.0 and Wtcat &amp;lt;60.0 THEN Wtcat ='50-60 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;60.0 and Wtcat &amp;lt;70.0 THEN Wtcat ='60-70 Kg';&lt;BR /&gt;.......................................................&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the note below in my log:&lt;BR /&gt;ID=4 Wtcat=&amp;lt;50 Kg _ERROR_=1&lt;BR /&gt;_N_=109&lt;BR /&gt;NOTE: Invalid numeric data, WEIGHT='57,7' , at line 290 column 3.&lt;/P&gt;&lt;P&gt;The same issue for ID=6&lt;BR /&gt;NOTE: Invalid numeric data, WEIGHT='D' , at line 286 column 4&lt;/P&gt;&lt;P&gt;And ID=4 was reported as &amp;lt;50 rather than &amp;gt;=50 because of the comma in weight value.&lt;BR /&gt;So I would like to fix this.&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 13:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818816#M323228</guid>
      <dc:creator>ndamo</dc:creator>
      <dc:date>2022-06-17T13:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Invalid numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818820#M323229</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I got the note below in my log:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ID=4 Wtcat=&amp;lt;50 Kg _ERROR_=1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;_N_=109&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NOTE: Invalid numeric data, WEIGHT='57,7' , at line 290 column 3.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This can't possibly come from the data you are showing. Please show us the actual data you are using in data set OLD, by creating working SAS data step code typing it in yourself (and testing it to make sure it works) or via &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: Invalid numeric data, WEIGHT='D' , at line 286 column 4&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;SAS can't read the letter D in as a numeric. So WEIGHT will be set to missing on this row.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;And ID=4 was reported as &amp;lt;50 rather than &amp;gt;=50 because of the comma in weight value.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Change the comma to a decimal point (a dot) and it will work. Or, use the &lt;A href="https://documentation.sas.com/doc/en/pgmmvacdc/9.4/leforinforref/n0aggga4tdr094n14ecw1smkhva7.htm" target="_self"&gt;COMMAX. informat&lt;/A&gt; used to read in the data to use commas to separate the integer from the decimal.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 13:41:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818820#M323229</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-17T13:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Invalid numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818854#M323245</link>
      <description>&lt;P&gt;your code does not look correct. also you should wrap it in if ^missing(weight) then do. How do you want to classify wtcat if weight is missing? you realize that missing weight is also &amp;lt;50 and would be classified as wtcat='&amp;lt;50 kg'. I don't think that's what you intended. also you need to use weight in your 2nd and 3rd if statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 16:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818854#M323245</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T16:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Invalid numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818860#M323247</link>
      <description>&lt;P&gt;you're getting that error because weight is evidently not numeric, but rather character, and you are trying to compare a character to a number. you need to convert your character weight variable to numeric to do a NUMERIC comparison. also, what does weight D mean?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 16:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818860#M323247</guid>
      <dc:creator>tarheel13</dc:creator>
      <dc:date>2022-06-17T16:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to fix Invalid numeric data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818872#M323251</link>
      <description>Thank you. My raw datasets contains many observations . My pgm consist of the category of the last weight for each obs.&lt;BR /&gt;&lt;BR /&gt;**Report the last weight and remove all missing data&lt;BR /&gt;DATA LASTWEIGHT;&lt;BR /&gt;SET DMWEIGHT;&lt;BR /&gt;WHERE WEIGHT IS NOT MISSING;&lt;BR /&gt;BY ID;&lt;BR /&gt;IF LAST.ID;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;PROC PRINT;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;*Split the weight to report the the weight category&lt;BR /&gt;DATA WGHTLAST(KEEP=ID VISIT WEIGHT WGHTCAT);&lt;BR /&gt;SET LASTWEIGHT;&lt;BR /&gt;LENGTH WGHTCAT $20;&lt;BR /&gt;IF WEIGHT &amp;lt;50.0 THEN WGHTCAT='&amp;lt;50 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;50.0 and WEIGHT&amp;lt;60.0 THEN WGHTCAT='50-60 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;60.0 and WEIGHT&amp;lt;70.0 THEN WGHTCAT='60-70 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;70.0 and WEIGHT&amp;lt;80.0 THEN WGHTCAT='70-80 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;80.0 and WEIGHT&amp;lt;90.0 THEN WGHTCAT='80-90 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;90.0 and WEIGHT&amp;lt;100.0 THEN WGHTCAT='90-100Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;100.0 and WEIGHT&amp;lt;110.0 THEN WGHTCAT='100 – 110 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;110.0 and WEIGHT&amp;lt;120.0 THEN WGHTCAT='110 – 120 Kg';&lt;BR /&gt;IF WEIGHT=&amp;gt;120.0 THEN WGHTCAT='&amp;gt;=120Kg';&lt;BR /&gt;&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;'D' means Not Done . I think I have to remove it but the issue is that user can enter the number both with comma and dot .&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2022 17:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fix-Invalid-numeric-data/m-p/818872#M323251</guid>
      <dc:creator>ndamo</dc:creator>
      <dc:date>2022-06-17T17:18:45Z</dc:date>
    </item>
  </channel>
</rss>

