- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-11-2013 11:16 AM
(4072 views)
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!
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
what is the error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Invalid data for Var3 in line 123
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So you have all the information you need. You have the invalid data message and the offending record. Case closed.