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='.';

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