![]() Chapter Contents |
![]() Previous |
![]() Next |
| LOSTCARD |
| Valid: | in a DATA step |
| Category: | Action |
| Type: | Executable |
| Syntax | |
| Without Arguments | |
| Details | |
| When to Use LOSTCARD | |
| When LOSTCARD Executes | |
| Examples | |
| See Also | |
Syntax |
| LOSTCARD; |
The LOSTCARD statement prevents SAS from reading a record from the next group when the current group has a missing record.
| Details |
When LOSTCARD executes, SAS takes these steps:
| Examples |
This example uses the LOSTCARD statement in a conditional construct to identify missing data records and to resynchronize the input data:
data inspect;
input id 1-3 age 8-9 #2 id2 1-3 loc
#3 id3 1-3 wt;
if id ne id2 or id ne id3 then
do;
put 'DATA RECORD ERROR: ' id= id2= id3=;
lostcard;
end;
datalines;
301 32
301 61432
301 127
302 61
302 83171
400 46
409 23145
400 197
411 53
411 99551
411 139
;
The DATA step reads three input records before writing an observation.
If the identification number in record 1 (variable ID) does not match the
identification number in the second record (ID2) or third record (ID3), a
record is incorrectly entered or omitted. The IF-THEN DO statement specifies
that if an identification number is invalid, SAS prints the message that is
specified in the PUT statement message and executes the LOSTCARD statement.
DATA RECORD ERROR: id=302 id2=302 id3=400 NOTE: LOST CARD. RULE:----+----1----+----2----+----3----+----4----+----5----+---- 4 302 61 5 302 83171 6 400 46 DATA RECORD ERROR: id=302 id2=400 id3=409 NOTE: LOST CARD. 7 409 23145 DATA RECORD ERROR: id=400 id2=409 id3=400 NOTE: LOST CARD. 8 400 197 DATA RECORD ERROR: id=409 id2=400 id3=411 NOTE: LOST CARD. 9 411 53 DATA RECORD ERROR: id=400 id2=411 id3=411 NOTE: LOST CARD. 20 411 99551 |
The numbers 14, 15, 16, 17, 18, 19, and 20 are line numbers in the SAS log.
| See Also |
Statement:
|
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.