Hi,
I need to create a pipe delimited file. I used the below code on mainframe. Input and the output that I got from my program given below. The code put 2 more double quotes around the text. How can I create the pipe delimited file without extra double quotes.
Thanks!!
OPTION MISSING=' ' ERROR=0; DATA ONE; INFILE INFILE ; INPUT PUT @1 FLD1 $CHAR9. @10 FLD2 $CHAR1277.; FILE OUTFILE DELIMITER='|' DSD; PUT FLD1-FLD2$;
INPUT:
Account_Number "SYNOPSIS" 123456789 "Private Limited Company" 345678901 "Public Limited Company" 675839674 "Unknown Company"
Output Received:
Account_Number|"""SYNOPSIS"""
123456789|"""Private Limited Company"""
345678901|"""Public Limited Company"""
675839674|"""Unknown Company"""
Hi, customer wants double quotes for the Synopsis string. I just tried without DSD. The output looks good now. Thanks!!
Remove the quotes from the input data string values.
Hi, customer wants double quotes for the Synopsis string. I just tried without DSD. The output looks good now. Thanks!!
Ask why they want such a non-standard format for the file? Quotes in delimited files are normally considered optional since they are used to mask delimiters in values. Since they are optional that is why the existing quotes in the actual value were doubled.
If the issue is just that you want to force quotes around values that do not require them the try using the ~ modifier on the PUT statement. Note do not include the quotes in the actual data values in your SAS dataset.
data _null_;
set have ;
file outfile dsd dlm='|' ;
put fld1 fld2 ~ ;
run;
Note that delimited files will also remove leading/trailing spaces from values. That is part of the whole point of generating a delimited file instead a fixed length field file.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.