BookmarkSubscribeRSS Feed
Ju
Calcite | Level 5 Ju
Calcite | Level 5

Hallo

how do I get rid of quotes (") in the txt-file I export from SAS?

Background:

My SAS script produces a file which contains one column containig the varchar expression. This file should be exported to txt (without headers).

At the moment the exported data in txt looks like that:

"k123   123  some text"

"k456   456 some other text"

What I need is:

k123   123  some text

k456   456 some other text

IMPORTANT NOTE: every row is one variable (even if it contains spaces inside)

Thank you in advance.

juila

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Hi,

What method are you using to get the data out?  Perhaps post some code?

If you use datastep with file, and a put statement with your variable, you can put it out any way you like, with/without quotes, formatted etc. 

Example:

data have;

  attrib some_text format=$200.;

  some_text="k123   123  some text"; output;

  some_text="k456   456 some other text"; output;

run;

data _null_;

  set have;

  file "s:\temp\rob\temp.txt";

  put some_text;

run;

Ju
Calcite | Level 5 Ju
Calcite | Level 5

Thank you for quick response.

I have the following code:

filename file_1 "c:\path~\file_1.txt";

                 data _null_;

                   set want;

                   file file_1 dsd dlm='';

                   put (_all_)(:);

       run;

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Yes, you have the DLM='' statement on there.  As your data contains spaces, SAS is helpfully quoting it.  Remove the DLM= option and it should work correctly.  You could also say DLM=','; to get the result.

Ju
Calcite | Level 5 Ju
Calcite | Level 5

Wow! It works!

Many thanks! You are great! 🙂

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 4595 views
  • 1 like
  • 2 in conversation