BookmarkSubscribeRSS Feed
Tom
Super User Tom
Super User

@Adumb wrote:
I'm new to this group and I'm hoping this is a one-off request. I send the file off to a different team so I'm not sure what they're using. I will certainly be asking more questions.

Yes, this is the desired output:
"abc"|""|"ghi"

Currently I'm getting this:
"abc"|" "|"ghi"

You can also try giving them a file that does not have any of the unnecessary quotes.

abc||ghi

There is no reason to have quotes unless the value contains the delimiter (or quotes).

Tom
Super User Tom
Super User

You could try making your own format that writes blank as bare quotes and then use that without the DSD option.

Example:

proc format;
value $equote (max=32767)
 ' '='""'
 other=[$quote.]
;
run;

data test;
  infile cards dsd truncover;
  input (c1-c3) (:$30.) n1-n3 ;
  file log dlm=',';
  format _character_ $equote.;
  put c1-c3 n1-n3 ;
cards;
1,2,3,4,5,6
a,b,,7,,9
;

Results:

"1","2","3",4,5,6
"a","b","",7,.,9
Tom
Super User Tom
Super User

If the requirement is just to quote the character values, and not the numeric values, then try ODS CSV.  You can use teh DELIMITER option to ask it to use | instead comma.

ods csv file=csv options(delimiter='|');
options missing=' ';
proc print data=test; run;
ods csv close;
options missing='.';

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
  • 17 replies
  • 29347 views
  • 4 likes
  • 7 in conversation