Desktop productivity for business analysts and programmers

Exporting text field to .txt file without quote qualifiers

Reply
Occasional Contributor
Posts: 12

Exporting text field to .txt file without quote qualifiers

Large insurance company using SAS EG 4.3. We use the GUI interface.

I have a very simplistic process flow that ends with a table that has a single column of data in it. The final step in my process is to export this column of data to a text file, in a specific network folder, where an IT batch picks up the file and does other things with it. This SAS query is new, and this job was previously done by Hyperion Brio.

My issue is that this column of data is alphanumeric, and so it's considered text. When I add in the 'export as a step in the process', it exports to the right location, but puts quotes around the data elements. When the IT batch goes to grab the data, it errors out when it encounters the quotes.

At this point, the IT batch is not editable...as I said, we are a large insurance company and so any change in an IT batch requires time, prioritization, etc. But if I can fix the SAS query, we don't have to go through that process.

Is there a way to export a text field into a .txt file (which is required...no .csv) without qualifying the text field with quotes?

Grand Advisor
Posts: 17,394

Re: Exporting text field to .txt file without quote qualifiers

I don't see an option via point and click, so most likely you'll have to add a program step.

Fortunately its a very simple one.

filename fileout "c:\_localdata\test.txt"; *path to folder with filename;

data _null_;

    file fileout;

    set sashelp.class;

    if _n_=1 then put "Name"; *Header information;

    put name; *variable to be exported;

run;

Occasional Contributor
Posts: 12

Re: Exporting text field to .txt file without quote qualifiers

Thanks. Having never done any programming within SAS (but having some programming background here and there in school), can you help me understand how to bake this code into my existing process flow? I have about four queries, then a filter & sort, and then this export in my current flow. How do I replace the export step with the code above?

Grand Advisor
Posts: 17,394

Re: Exporting text field to .txt file without quote qualifiers

Delete the export step.

Add a program (File>New>Program)

Modify the program so that it works for you set up.

Specifically, specify the file location, the variable name and for the SET statement, make sure it refers to the dataset you need.

You'll need to save the program somewhere in addition to the project.

I think you'll have to manually connect the program if you'd like it to appear at the end. Right Click the data set you're exporting, select Link To and select the program.

Occasional Contributor
Posts: 12

Re: Exporting text field to .txt file without quote qualifiers

Thanks...getting closer! I have replaced the variables in your code above with my information, however now I'm getting this error:

ERROR: Insufficient authorization to access /usr/apps/sas/ConfigGrid/Lev1/SASAdhoc/C:\Temp\test\RCC_LETTER_INPUT.TXT.

My code is:

filename fileout "C:\Temp\test\RCC_LETTER_INPUT.TXT"; *path to folder with filename;

data _null_;

    file fileout;

    set sashelp.class;

    if _n_=1 then put "Policy_Number"; *Header information;

    put BLNG_CNTRCT_YR_MTH_ID; *variable to be exported;

run;

I get the same error when I attempt to write out to a network folder (which will be the eventual solution). I do have full write privileges for each location.. I realize you've basically solved my problem and that I'm likely dealing with a new issue...so let me know if I should open a new topic for this. Thanks.

Community Manager
Posts: 2,697

Re: Exporting text field to .txt file without quote qualifiers

You're running into the confusion that happens when SAS is "over there" but EG is running on your PC "right here".

See this blog post for some guidance:

Export and download any file from SAS Enterprise Guide - The SAS Dummy

Chris

Grand Advisor
Posts: 9,584

Re: Exporting text field to .txt file without quote qualifiers

You need have right to write a file under OS command.

filename fileout temp;

data _null_;

    file fileout dsd  ;

    set sashelp.class;

    if _n_=1 then put "Policy_Number"; *Header information;

    put BLNG_CNTRCT_YR_MTH_ID ~ ; *variable to be exported;

run;


data _null_;

infile fileout;

input;

list;

run;



Xia Keshan

SAS Super FREQ
Posts: 676

Re: Exporting text field to .txt file without quote qualifiers

Please show what your text column looks like.

A test using EG6.1 (I know not your version) shows the following:

This data set

Is exported as:

newColumn,Name,Age

"Alfred,M,14",Alfred,14

"Alice,F,13",Alice,13

"Barbara,F,13",Barbara,13

"Carol,F,14",Carol,14

"Henry,M,14",Henry,14

Since the first column has the delimiter as part of the data, it is enclosed in double quotes, but the other columns that do not have delimiters are not put into quotes.

Now I do not have EG4.3 available to test, please check your data for the delimiter (the comma) in your data

Ask a Question
Discussion stats
  • 7 replies
  • 2655 views
  • 6 likes
  • 5 in conversation