Help using Base SAS procedures

Porblem with unmatched double quotes using proc export

Reply
Occasional Contributor
Posts: 18

Porblem with unmatched double quotes using proc export

Hello All,

 

I am using proc export to export data into .csv file and facing some problem. In my data " is present.When I am exporting it using proc export , it is getting repeated 4 times and " becomes """".  I have seen some solutions on this but unfortunately I need to fix this using proc export only. This happens only with " (unmatched double quotes). All other special characters like @,#,$ are exported correctly. I am using SAS 9.2 EG on Unix environment.

 

Can anyone helps me why proc export behaves like this and what is a solution for this?

 

Regards,

AD.

Super User
Super User
Posts: 7,401

Re: Porblem with unmatched double quotes using proc export

If your data contains ", then the output file needs to have more quotes to indicate that the overall string starts from and finishes at.  E.g.

Abcde"efg

If I put one set of quotes round this:

"Abcd"efg"

Thats an invalid string, so need to add more quotes:

""Abcd"efg""

 

Basically if you want a file to look how you want, I would write the datastep to output it.  Also check this post:

https://communities.sas.com/t5/SAS-Procedures/Proc-Export-adding-extra-quotation-marks/td-p/90021

Super User
Posts: 10,500

Re: Porblem with unmatched double quotes using proc export

I have had to read files that some creatively modified the rules for quotes for delimited text such that I had values like

 

column1, "Some text with, and " in the middle", 45.3, column4 text.

 

And those break almost every standard import tool.

 

Manually write a couple of lines similar to what I show (or you seem to want). Then use proc import to read the file. Or import into Access or some other data base as a CSV and see what you get.

 

One might ask what you will do with the resulting file.

 

Ask a Question
Discussion stats
  • 2 replies
  • 99 views
  • 0 likes
  • 3 in conversation