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

 A business partner requires a pipe-delimited (|) record format where missing values are represented as a zero length field or two consecutive pipe characters (||).  We have tried formats, compress() function, and system option MISSING='' to force length zero for missing values in a PUT statement but the record always returns a single blank space between two pipe characters (| |).  Is there a way to remove the single blank space for output without having to remove blank spaces after the file is created with a utility program (e.g. PowerShell)?  We are trying to automate this process if possible.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Jim_Cooper_hmsa,

 

Add the DSD option to the FILE statement.

 

Example:

93    data _null_;
94    file log dlm='|' dsd;
95    x='ABC';
96    y=' ';
97    z='DEF';
98    m=.;
99    n=123;
100   put x y z m n;
101   run;

ABC||DEF||123
NOTE: DATA statement used (Total process time):

The same code without the DSD option yields

ABC| |DEF|.|123

 

 

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @Jim_Cooper_hmsa,

 

Add the DSD option to the FILE statement.

 

Example:

93    data _null_;
94    file log dlm='|' dsd;
95    x='ABC';
96    y=' ';
97    z='DEF';
98    m=.;
99    n=123;
100   put x y z m n;
101   run;

ABC||DEF||123
NOTE: DATA statement used (Total process time):

The same code without the DSD option yields

ABC| |DEF|.|123

 

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

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
  • 1 reply
  • 613 views
  • 9 likes
  • 2 in conversation