BookmarkSubscribeRSS Feed
ad123123
Fluorite | Level 6

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.

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

ballardw
Super User

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.

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 993 views
  • 0 likes
  • 3 in conversation