Help using Base SAS procedures

Error when importing data into sas

Reply
Super Contributor
Posts: 256

Error when importing data into sas

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?

Super User
Super User
Posts: 6,498

Re: Error when importing data into sas

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

Super Contributor
Posts: 256

Re: Error when importing data into sas

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

Super User
Posts: 10,466

Re: Error when importing data into sas

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.

Ask a Question
Discussion stats
  • 3 replies
  • 201 views
  • 0 likes
  • 3 in conversation