Desktop productivity for business analysts and programmers

Export txt

Reply
Occasional Contributor
Posts: 10

Export txt

When I export a file in txt, at the beginning and end of each line appears "(quotes) how do I prevent this from happening?

Community Manager
Posts: 2,956

Re: Export txt

How are you exporting this?  Using EG menus or code? Try File->Export->Export [DATANAME], and select a CSV type.

Occasional Contributor
Posts: 10

Re: Export txt

Posted in reply to ChrisHemedinger

I need to export in txt
With the table open I'm going to Export >> Export Step in Project
I select the format, in case txt and end.

When I do this procedure it is putting quotation marks at the beginning and end of each line.

Super User
Posts: 19,878

Re: Export txt

Post the code you're using.

Occasional Contributor
Posts: 10

Re: Export txt

Não estou exportando através de código.
Com a tabela aberta estou indo em Export >> Export Step in Project
Seleciono o formato, no caso txt e fim.

Quando faço esse procedimento ele está colocando aspas no início e no fim de cada linha.

Occasional Contributor
Posts: 10

Re: Export txt

I am not exporting through code.
With the table open I'm going to Export >> Export Step in Project
I select the format, in case txt and end.

When I do this procedure it is putting quotation marks at the beginning and end of each line.

SAS Super FREQ
Posts: 326

Re: Export txt

What version of EG (listed in Help->About) are you using?  In newer versions of EG, only values that contain the delimiter will be wrapped in quotes when exported to text (to avoid the ambiguity).

Occasional Contributor
Posts: 10

Re: Export txt

Posted in reply to CaseySmith

version 5.1

Super User
Posts: 7,868

Re: Export txt


egamorim wrote:

I am not exporting through code.
With the table open I'm going to Export >> Export Step in Project
I select the format, in case txt and end.

When I do this procedure it is putting quotation marks at the beginning and end of each line.


There is ALWAYS code in SAS. EG is just a code generator, and as soon as a node is run, you get a tab with the code that was sent to the workspace server.

To be able to recreate your situation, we need

- that code I mentioned (to make sure that our actions in EG generate the same code)

- your dataset that you exported. Use the macro provided in https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... to convert your dataset to a data step, and post that here in a code window (6th or 7th icon above the posting window).

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Community Manager
Posts: 2,956

Re: Export txt

Posted in reply to KurtBremser

Actually, as much as I hate to correct my friend @KurtBremser, there is no SAS code for this step initated from "Export as a Step".  EG reads the data and uses local routines to generate a text file.  As Casey said, earlier versions of EG added unnecessary quotes -- this is corrected in EG 7.1.

 

You can, however, use SAS code to achieve what you need.  PROC EXPORT, ODS CSV, and simple DATA step can all be used to generate text files from data.  Your challenge would then be to copy that data file from your SAS server to your local PC, and that's what the Copy Files task is good for.  Here's a blog post that leads you through the steps.

Occasional Contributor
Posts: 10

Re: Export txt

Posted in reply to ChrisHemedinger

Yes, as mentioned by ChrisHemedinger, there is no code for the way I am doing it.

 

My table contains only 1 column called Mailing in text format.

 

Could you code in code how can I export this table into text format?

Super User
Posts: 7,868

Re: Export txt


egamorim wrote:

Yes, as mentioned by ChrisHemedinger, there is no code for the way I am doing it.

 

My table contains only 1 column called Mailing in text format.

 

Could you code in code how can I export this table into text format?


That's simple:

data have;
input email :$100.;
cards;
user.user@domain.com
another_user@some-domain.com
;
run;

data _null_;
file '$HOME/test.txt';
set have;
put email;
run;

The file test.txt looks like that:

user.user@domain.com
another_user@some-domain.com

As you can see, no quotes.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Export txt

Posted in reply to KurtBremser

Okay, but it still did not work out.


I am illustrating in the attached image.

 

Notice that in EG the quotes do not appear, but in the yes txt.


exemplo.jpg
Super User
Posts: 7,868

Re: Export txt

You are using the export task from EG instead of the code I gave you. Don't be surprised.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Export txt

Posted in reply to KurtBremser

Can I export txt to my local machine?
On my desktop?

Ask a Question
Discussion stats
  • 19 replies
  • 307 views
  • 3 likes
  • 5 in conversation