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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 9984 views
  • 0 likes
  • 2 in conversation