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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.