SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Ouput txt file without quotation marks and maintain numeric values

Reply
Occasional Contributor
Posts: 10

Ouput txt file without quotation marks and maintain numeric values

Hi

I am using a file writer transformation in DI studio 4.4 to write a dataset to a text file.  I am faced with two problems, firstly every fiels is enclosed in quotation marks.  I believe this is because within some of the field I have non alphanumeric characters like "-".  The second issue I have is that there is a field with numeric characters.  They look fine in the dataset but when exported they are exported as 2.99e6 (or something similar) this ends up being 290000.  Most importantly how can I maintain the number in the field? secondly how can I export without quotation marks.

I have managed to export without quotation marks by editing the code to remove all references to "quote" (see below) although I would rather use a standard transformation if possibkle than modify one, VAR 5 is the numeric field.  I have highlighted the fields I remove/ modify to get output without quotes.


%let SYSLAST = work.W4VOE3O;

data _null_;
   set &SYSLAST;
      attrib VAR1 length = $3;

     attrib VAR2 length = $3;

     attrib VAR3 length = $3;

     attrib VAR5 length = 8;
            quote='"';
      file "$DISC_FTP/info_today_date1._&tf_hour.00.txt" LRECL=32760 dlm='|';
     
         put
            quote +(-1)VAR1  +(-1) quote

               quote +(-1)VAR2  +(-1) quote

               quote +(-1)VAR3  +(-1) quote

               quote +(-1)VAR4  +(-1) quote

               quote +(-1)VAR5  +(-1) quote
                        ;

run;

Thanks

Super User
Posts: 5,260

Re: Ouput txt file without quotation marks and maintain numeric values

About the numerical variables, any specified format should be honored.

The quotes seems a bit more frustrating :smileyconfused:

Your option would be to use User written body ( as you probably already tested), but that's not recommended.

An option would be to create a User Written File Writer transformation. With this, you will get the data types and format of all output variables in your target file as macro variables, so you could make the code dynamic.

In my opinion, both File reader and Writer transformations seems like an early hack, and should be candidates for enhancements.

Data never sleeps
New Contributor
Posts: 2

Re: Ouput txt file without quotation marks and maintain numeric values

"You must select "Treat consecutive delimiters as a single delimiter" in the external file properties (File Parameters tab) to prevent the double quotation marks from being included in the data."

And it worked to me.

Valued Guide
Posts: 3,208

Re: Ouput txt file without quotation marks and maintain numeric values

Why not use: SAS(R) 9.4 Formats and Informats: Reference The $quote. format? It does the thing you described. Doubling somet thing as usual conention incuded. 

---->-- ja karman --<-----
Valued Guide
Posts: 3,208

Re: Ouput txt file without quotation marks and maintain numeric values

The other mentioned issue with numerics is known as precision. Apply a correct format and rounding is included. https://support.sas.com/techsup/technote/ts654.pdf 

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 4 replies
  • 1551 views
  • 1 like
  • 4 in conversation