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

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"""
SAS@EMMAUS
1 ACCEPTED SOLUTION

Accepted Solutions
gandikk
Obsidian | Level 7

Hi, customer wants double quotes for the Synopsis string. I just tried without DSD. The output looks good now. Thanks!!

SAS@EMMAUS

View solution in original post

4 REPLIES 4
ballardw
Super User

Remove the quotes from the input data string values.

gandikk
Obsidian | Level 7

Hi, customer wants double quotes for the Synopsis string. I just tried without DSD. The output looks good now. Thanks!!

SAS@EMMAUS
Reeza
Super User
If this question is answered, please mark the correct solution. In this case you can mark your own answer about dropping the DSD option, which causes the double quotes. Note that double quotes is usually a standard for character variables to mask any quotes or other possible delimiters within the text field.
Tom
Super User Tom
Super User

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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

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
  • 4 replies
  • 2007 views
  • 0 likes
  • 4 in conversation