BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nbonda
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

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

PG
nbonda
Obsidian | Level 7

Is there any other option without changing my entire code . Because I have 30 similar code with lot of  variables in input statement.

Ksharp
Super User

Code: Program

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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 919 views
  • 4 likes
  • 3 in conversation