@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).
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
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.