BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,

I am trying to read a text file using "infile" statement, where data can come in either of delimiters - comma or tilda.

We have only SAS 8.2 Version. I saw that this option in infile statement - DLMSTR has facility to read either of ways that data will come and is applicable in SAS 9 version.

Do we have an equivalent option in SAS 8.2 Version. If not, how to read data if the file comes in either of those above delimiters?

thanks in advance,
Sasbase9
5 REPLIES 5
Oleg_L
Obsidian | Level 7
If I understand your question correctly than you can do following:

[pre]
data cc;
infile cards dlm=',~';
input a $ b $ c ;
cards;
A,1,13
B~2,15
c,D~20
;
[/pre]

Oleg. Message was edited by: Oleg_L
advoss
Quartz | Level 8
I ran Oleg_L's code on a mainframe with SAS8.2 and it worked.
Peter_C
Rhodochrosite | Level 12
the DLM='constant' option of the infile statement lists alternative delimiters all/any of which are used to parse the infile buffer
When you need to use different delimiters at different stages of input, use DLM=variable. The variable can change during the running of the data step in ways that the 'constant' cannot.

peterC emphasise that characters in the DLM are alternatives

Message was edited by: Peter.C
Ksharp
Super User
Hi.
Maybe you can use scan() function to achieve it.
Not test.

[pre]
data cc;
infile cards;
input ;
a=scan(_infile_,1,',~');
b=scan(_infile_,2,',~');
c=scan(_infile_,3,',~');
cards;
A,1,13
B~2,15
c,D~20
;
run;
proc print noobs; run;
[/pre]


Ksharp
chang_y_chung_hotmail_com
Obsidian | Level 7
...
> I saw that this option
> in infile statement - DLMSTR has facility to read
> either of ways that data will come and is applicable
> in SAS 9 version.
...
No. DLMSTR= option lets you specify a multi-character delimiter. DLM= option lets you specify single-character delimiter(s). A rather big difference.
[pre]
data one;
infile cards dlmstr="+|+" missover;
input (v1-v3) (:$8.);
cards;
1+++|+2||++|+3
;
run;

proc print data=one;
run;
/* on lst
Obs v1 v2 v3
1 1++ 2||+ 3
*/


data two;
infile cards dlm="+|+" missover;
input (v1-v3) (:$8.);
cards;
1+++|+2||++|+3
;
run;

proc print data=two;
run;
/* on lst
Obs v1 v2 v3
1 1 2 3
*/
[/pre]

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2266 views
  • 0 likes
  • 6 in conversation