SAS Component Language Dictionary |
Sets the token delimiters for the FGET function
sysrc=FSEP(file-id,delimiter);
|
-
sysrc
-
contains the return code for the operation:
0 |
successful |
0 |
not successful |
Type:
Numeric
-
file-id
-
specifies the identifier that was assigned
when the file was opened. If file-id is invalid,
the program halts.
Type: Numeric
-
delimiter
-
specifies the token delimiter that separates
items in the File Data Buffer (FDB). If multiple characters are specified,
each character is considered a delimiter. The default delimiter is a blank.
Type:
Character
Suppose the external file contains data in this form:
John J. Doe,Male,25,Weight Lifter
Note that each field is separated by a comma.
Read the file identified by the fileref THEFILE, using
the comma as a separator, and write the values for NAME, GENDER, AGE, and
WORK to the LOG window:
fileid=fopen('thefile');
rc=fsep(fileid,',');
sysrc=fread(fileid);
rc=fget(fileid,cval);
do while (rc ne -1);
put cval=;
rc=fget (fileid,cval);
end;
rc=fclose(fileid);
The output of the program is
cval=John J. Doe
cval=Male
cval=25
cval=Weight Lifter
FGET
FREAD
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.