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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 921 views
  • 0 likes
  • 3 in conversation