BookmarkSubscribeRSS Feed
anming
Pyrite | Level 9

For an external file employee.txt like:

susan*12/29/1970*10
micheal**6

 

data employee;
infile "/special path/employee.txt" dlm='*' dsd;
input employee $ bdate: mmddyy10. years;
run;

 both dlm and dsd are needed for proper input. However, there is no comma in the input data but only two stars for a missed value. Why is a dsd required? I read a few documents and posters. It seems it is still confused.

2 REPLIES 2
ballardw
Super User

DSD is required to treat two consecutive delimiters as a missing value as well as to allow the delimiter characters to appear as part of a value inside quoted text. Without the DSD option list input as you are using will treat consecutive delimiters as a single delimiter and the values would be read incorrectly.

 

The explicit DLM is going to be needed since you apparently have a character other than the comma as the delimiter. Comma is the default delimiter.

Tom
Super User Tom
Super User

The default is to use space as the delimiter and to treat multiple delimiters as one.  That makes sense when space is the delimiter because you normally use multiple spaces to make the data columns align for when humans view the file.  To treat adjacent delimiters as marking a missing value you need the DSD option.  But when you use the DSD option the default delimiter is now going to be a comma instead of space.  So to use asterisk instead of comma you need to use the DLM option to override the default delimiter.  Note that the DSD option will also change how quotes are treated.  Quotes around values are removed and any delimiter enclosed in quotes is treated as part of the data and not as a delimiter.

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1133 views
  • 2 likes
  • 3 in conversation