BookmarkSubscribeRSS Feed
jenni_kang
Calcite | Level 5

Hello experts!

I am unsure as to the reason why there is a note of invalid numeric, (shown below)

NOTE: Invalid numeric data, temp='20.2' , at line 1306 column 8.
NOTE: Invalid numeric data, hum='47.3' , at line 1307 column 7.
NOTE: Invalid numeric data, pressure='1002.3' , at line 1308 column 

but the value temp= '20.2' is the one I want to be outputted.

This is a sample of what I have.

	informat no best32. 
          date ddmmyy10. 
          time time20.3 
		  negmin best32. 
          negavg best32. 
          negmax best32. 
          posmin best32. 
          posavg best32. 
          posmax best32. 
          state best32.
          temp $6. 
          tempunit $2. 
          hum $6. 
          pressure $8. ;
         format no best12. 
         date ddmmyy10. 
         time time20.3 
         negmin best12. 
         negavg best12. 
         negmax best12. 
         posmin best12. 
         posavg best12. 
         posmax best12. 
         state best12.
         temp $6. 
         tempunit $2. 
         hum $6. 
         pressure $8. ;
      input
                  no
				  date
				  time
				  negmin
				  negavg
				  negmax
				  posmin
				  posavg
				  posmax
				  state
				  temp
				  tempunit
				  hum
				  pressure
      ;
      if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
      run;
data work.class1;
set work.class;
tempc= temp/10 ;
hump= hum/10  ;
press= pressure/10 ;

drop tempunit temp hum pressure;

datetime = dhms(date,0,0,0)+time;
format datetime datetime15.;

run;

How do I get the correct output?

4 REPLIES 4
VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

@jenni_kang replace this

         temp $6. 
         hum $6. 
         pressure $8.

with this

         temp 8. 
         hum 8. 
         pressure 8.
jenni_kang
Calcite | Level 5

After trying your suggestion, the error message comes back as this

NOTE: Invalid data for temp in line 22 54-57.
NOTE: Invalid data for hum in line 22 64-67.
NOTE: Invalid data for pressure in line 22 71-76.
Tom
Super User Tom
Super User

@jenni_kang wrote:

After trying your suggestion, the error message comes back as this

NOTE: Invalid data for temp in line 22 54-57.
NOTE: Invalid data for hum in line 22 64-67.
NOTE: Invalid data for pressure in line 22 71-76.

The log will also show the actual value of line 22 so you can see exactly what is columns 54 to 76 and why they don't work as numbers. Without that it is hard to give good advice for how to handle those cases.  It might be as simple as ignoring the error because it is clear that the text on that lines means that those numbers were not recorded.  For example if you generated that text from R it might but NA for missing values. So having TEMP be missing for line 22 is what you want to happen.

ballardw
Super User

Likely it would help to post the LOG with ALL of the code along with all of the notes and such that is generating the error.

 

Since column positions may be important make sure to paste log into a code box opened with the forum's {I} or "running man" icon.

 

The INFILE statement has a lot of interaction with how things are read and is important to include when reading external data.

 

Though I do wonder why you are reading those variables as CHARACTER

 

temp $6. 
hum $6. 
pressure $8. 

when you want to do arithmetic with them:

tempc= temp/10 ;
hump= hum/10  ;
press= pressure/10 ;

I suspect if you remove the $ from informat for those variables the problem goes away...

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1302 views
  • 0 likes
  • 4 in conversation