Usage Note 33385: DLMSTR= option used to specify multi-character string as a delimiter
The DLMSTR= option for the INFILE statement is available beginning in SAS 9.2. DLMSTR stands for "delimiter string'. This option enables programmers to specify a multi-character string as a delimiter. For example, DLMSTR="-/-" treats these three characters, in this order, as a delimiter. Prior to this option, each individual character specified in the DLM= option would have been treated singularly as a delimiter.
The DLMSTR= option supports specifying a character variable after the equal sign. The value in the variable is used as the delimiter.
DLMSTR= is also supported on the FILE statement, enabling users to write data with multi-character string delimiters.
If there are consecutive delimiter strings in the file which indicate missing values, the DLMSTR= option will not read the file properly until SAS 9.3. This SAS note 38147 gives more information about this issue.
If there are consecutive delimiter strings in the file that is being read in and the release of SAS is prior to 9.3, the PRXCHANGE function with _INFILE_ can be used to change the multiple delimiters to one delimiter and then reread _INFILE_. See the third program under the Full Code tab.
Operating System and Release Information
Microsoft® Windows® for 64-Bit Itanium-based Systems
Microsoft Windows Server 2003 Datacenter 64-bit Edition
Microsoft Windows Server 2003 Enterprise 64-bit Edition
Microsoft Windows XP 64-bit Edition
Microsoft® Windows® for x64
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows XP Professional
64-bit Enabled AIX
64-bit Enabled HP-UX
64-bit Enabled Solaris
Linux for x64
OpenVMS on HP Integrity
Solaris for x64
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
Use the DLMSTR= option on the INFILE and FILE statements to specify multi-character strings as delimiters.
/* Specify multiple delimiters with the DLMSTR= option along with */
/* the DSD option so that the string @# is considered one delimiter */
infile datalines dlmstr='@#' dsd truncover;
input x y z;
/* Put this data set out to a file and use DLMSTR= option on */
/* the FILE statement to specify the delimiter string. */
file 'c:\myfile.txt' dlmstr='@#';
put x y z;
/* If your file contains consecutive delimiter strings and you're */
/* running SAS prior to 9.3, you will need the following program. */
/* Create a file with consecutive delimiter strings so you can */
/* test the program that follows. Specify the path of your */
/* choice inside quotes on the FILE statement. */
/* If there are consecutive delimiter strings in the file you're*/
/* reading, you can use PRXCHANGE to temporarily change them to */
/* a single delimiter so the file is read correctly. */
/* The null INPUT statement reads a record into the input buffer*/
/* which is accessible as the automatic variable, _INFILE_. Use */
/* the PRXCHANGE function to temporarily change the @# delimiter*/
/* string to a ~. That character was declared as the delimiter */
/* with the DLM= option on the INFILE statement so the INPUT */
/* statement can now read the file properly. */
infile 'your-file-specification' truncover dlm='~' dsd;
input @1 a b c d ;
Obs x y z
1 123 -456 789
/* results in the file created with second DATA step */
/* results of using PRXCHANGE to read the consecutive delimiter strings */
Obs a b c d
1 123 456 . 789
Beginning in SAS 9.2, the DLMSTR= option on the INFILE statement enables programmers to specify a multi-character string as a delimiter.
SAS Reference ==> Statements ==> File-handling ==> INFILE SAS Reference ==> Statements ==> File-handling ==> FILE