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.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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