BookmarkSubscribeRSS Feed
brophymj
Quartz | Level 8

I'm getting an error message when I try to import a dataset where one of the fields is a number. the reason for the error is that all the cells contain a number except one cell that contains a blank.

data help

infile start DLM = ',' DSD MISSOVER LRECL = 10000;

     format field1 8.

                field2 8.

                   ...

                   ...

                              ;

     input field1

              field2

                   ...

                    ...

                              ;

run;

Error message I'm getting is:

Invalid data for field1 in line 36371 1-1

I know this is just a cosmetic thing as it doesn't really cause problems with my end result, i just want to tidy it up so that I don't get those nasty looking errors. I would of though the blank cell would be left blank without error.

Any clean approaches here?

3 REPLIES 3
Tom
Super User Tom
Super User

Actual blanks will not cause that problem.  Must be some other character.

brophymj
Quartz | Level 8

Hi Tom, yes you are right. The cell has a character which is an error. The character is "/*". Is there code you can put in the above that deletes this case so that no error appears in the log?

Thanks

ballardw
Super User

You can suppress the message using:

input field1 ??

I would be cautious with that unless you know that the only thing that will cause that is a limited case.

Another approach I have used is to create a custom informat to specify specific known strings as missing numeric. That way I get a message when unexpected values show up.

proc format;

invalue myproblemfield

'/*' = .

;

run;

and use

informat field1 myproblemfield.; before the input statement.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 755 views
  • 0 likes
  • 3 in conversation