DATA Step, Macro, Functions and more

Missing values in infile statement

Reply
Frequent Contributor
Posts: 138

Missing values in infile statement

Hi everyone,

I am trying to read a txt file into SAS using the infile statement.

The data look like this:

Var1      Var2          Var3

"John" , "Smith",      4.3

"Bob",    "Jones" ,    5.2

"Sarah",  "Johnson"  ,  .

I am using the following code:

data newdata;

infile 'filelocation.txt' dsd missover;

input var1 $ var2 $ var3;

run;

The problem is that I am getting error messages for instances where Var3 is missing (missing values are noted with a period).


Any help is much appreciated.

Thanks!

Respected Advisor
Posts: 3,799

Re: Missing values in infile statement

Posted in reply to Walternate

what is the error?

Frequent Contributor
Posts: 138

Re: Missing values in infile statement

Posted in reply to data_null__

Invalid data for Var3 in line 123

Respected Advisor
Posts: 3,799

Re: Missing values in infile statement

Posted in reply to Walternate

Did SAS show the the line as in this example.

19         filename FT15F001 temp;
20         data newdata;
21            *infile 'filelocation.txt' dsd missover;
22            infile FT15F001 dsd missover;
23            input var1 $ var2 $ var3;
24            parmcards;
28         ;;;;

NOTE:
The infile FT15F001 is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: Invalid data for var3 in line
3 23-25.
RULE:     ----+----
1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
3         "Sarah""Johnson"  ,  x 25
var1=Sarah var2=Johnson var3=
. _ERROR_=1 _N_=3
NOTE:
3 records were read from the infile (system-specific pathname).
      The minimum record length was
25.
      The maximum record length was
26.
NOTE: The data set WORK.NEWDATA has
3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time          
0.00 seconds
      cpu time           
0.02 seconds
     
Frequent Contributor
Posts: 138

Re: Missing values in infile statement

Posted in reply to data_null__

Yes.

Respected Advisor
Posts: 3,799

Re: Missing values in infile statement

Posted in reply to Walternate

So you have all the information you need.  You have the invalid data message and the offending record.  Case closed.

Ask a Question
Discussion stats
  • 5 replies
  • 500 views
  • 2 likes
  • 2 in conversation