04-30-2013 12:30 PM
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;
attrib VAR1 length = $3;
attrib VAR2 length = $3;
attrib VAR3 length = $3;
attrib VAR5 length = 8;
file "$DISC_FTP/info_today_date1._&tf_hour.00.txt" LRECL=32760 dlm='|';
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
05-07-2013 06:25 AM
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.
09-12-2014 08:04 AM
09-12-2014 08:54 AM
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.
09-12-2014 08:57 AM
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