Help using Base SAS procedures

Proc Export adding extra quotation marks

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

Proc Export adding extra quotation marks

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?


Accepted Solutions
Solution
‎08-10-2012 01:17 PM
Contributor
Posts: 27

Re: Proc Export adding extra quotation marks

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


All Replies
Solution
‎08-10-2012 01:17 PM
Contributor
Posts: 27

Re: Proc Export adding extra quotation marks

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

PROC Star
Posts: 7,474

Re: Proc Export adding extra quotation marks

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

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