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

I am trying to export a SAS dataset to a text file but when I use proc export it is adding extra quotation marks.  I need the output file to look just like the dataset.  An example of what the dataset looks like and what the text file looks like after it has been exported are as follows:

Dataset example (each line is a different observation):

"Text stuff

Other text;

More text

Some more text"

Output file example after using proc export:

"""Text stuff"

Other text stuff;

More text

"Some more text"""

Example of proc export code:

proc export data=test dbms=DLM outfile="textfile.txt" replace;

  delimiter='0a'x;

run;

As you can see it inserts extra quotation marks at the beginning on line 1, adds a quotation mark at the end of line 1, adds a quotation mark at the beginning of line 4, and extra quotation marks at the end of line 4.

Is there anyway to prevent this?

1 ACCEPTED SOLUTION

Accepted Solutions
lsirakos
Calcite | Level 5

Nevermind, found a way to get this to work without using proc export.  Solution is as follows:

libname ssd '[drive]:\[your_folder]\proj\' ;
data _null_ ;         /* No SAS data set is created */
    set ssd.income ;
    FILE  '[drive]:\[your_folder]\rawfile.txt' ;    /* Output Text File */
    PUT var1 ;
run ;

via:

http://www.ciser.cornell.edu/FAQ/SAS/write_delimited_file.shtml

View solution in original post

2 REPLIES 2
lsirakos
Calcite | Level 5

Nevermind, found a way to get this to work without using proc export.  Solution is as follows:

libname ssd '[drive]:\[your_folder]\proj\' ;
data _null_ ;         /* No SAS data set is created */
    set ssd.income ;
    FILE  '[drive]:\[your_folder]\rawfile.txt' ;    /* Output Text File */
    PUT var1 ;
run ;

via:

http://www.ciser.cornell.edu/FAQ/SAS/write_delimited_file.shtml

art297
Opal | Level 21

However, if you want to take advantage of proc export's obtaining and outputting the variable name(s) on the first row, it is easy to do.

After running proc export, press function key F4.

That will retrieve the statement that was submitted.  If your variable was called text, there will be a line towards to bottom of the program that shows:

put text $;

if you change that to, say:

put text char30.;

you will get the desired output file.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 10309 views
  • 0 likes
  • 2 in conversation