I have a code that read a text file, with delimiter pipe (|)
data sample;
Infile 'C:\mydata\test.txt' DSD DLM='|' LRECL=1024 MISSOVER FIRSTOBS=1 TERMSTR=LF;
Input fname :$CHAR20.
lname :$CHAR30.
city :$CHAR40.
run;
sample text file:
Jen|Turner|'Chicago'
David||'New York'
Michael|ybarra|Detroit
If I use DSD option ,SAS not reading single quotes and consecutive delimiters reading as missing value...., Without DSD option SAS reads single quotes, but consecutive delimiters are not reading as missed value.
Is there any infile options or a statement that reads single quotations in data and consider missing value for consecutive delimiter.? Thank you
Use the tilde format modifier :
data sample;
length fname $20 lname $30 city $40;
Infile datalines dsd DLM='|' MISSOVER;
Input fname ~ lname ~ city ~;
datalines;
Jen|Turner|'Chicago'
David||'New York'
Michael|ybarra|Detroit
;
proc print data=sample; run;
PG
Use the tilde format modifier :
data sample;
length fname $20 lname $30 city $40;
Infile datalines dsd DLM='|' MISSOVER;
Input fname ~ lname ~ city ~;
datalines;
Jen|Turner|'Chicago'
David||'New York'
Michael|ybarra|Detroit
;
proc print data=sample; run;
PG
Is there any other option without changing my entire code . Because I have 30 similar code with lot of variables in input statement.
data sample;
Infile datalines dsd DLM='|' MISSOVER;
Input fname ~ : $20. lname ~ :$20. city ~ : $20.;
datalines;
Jen|Turner|'Chicago'
David||'New York'
Michael|ybarra|Detroit
;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.