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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 774 views
  • 4 likes
  • 3 in conversation