The SAS Output Delivery System and reporting techniques

Add The Columns to Text File

Reply
N/A
Posts: 0

Add The Columns to Text File

Hello All

I'm not sure, where should I post message about Data Integration Studio, so I'll try to do it here.

I use FileWriter in DIS to copy table to text file. It works good, but I need to add column names in first line. Help please, if somebody knows how to do it.

If nobody knows, than it will be great if you write a piece of code which will do this.

Thank you
N/A
Posts: 0

Re: Add The Columns to Text File

Hi again
I have already found the solution of my question.
It is necessary to add the next code to user written code in FileWriter.

data _null_;
set &syslast;

attrib Field1 length = 8;
attrib Field2 length = $40;
attrib Field3 length = 8 format = commax16.2;

file "D:\MyFolder\FileName.txt" dlm = ";";

if _n_ = 1 then put 'Field1;Field2;Field3';

put Field1
Field2
Field3;

run;
N/A
Posts: 0

Re: Add The Columns to Text File

Ihor

you might like to build a generic "transform" as a proc print report using ODS to write to CSV. By default, you can get all columns written with even simpler code, like :[pre]
ods close _all_ ;
ods csv file= "&_extfile" /* pulled from generic report surface */
proc print data= &_input1 /* pulled from generic report surface */
noobs ;
var _all_ ;
run;
ods _all_ close ;
ods listing ;
[/pre]
Although, for all columns, you really don't need that VAR statement, I placed it there as a reminder that you can probably use the DI Studio surface to select the columns you want to be written, and these would be placed in a macro variable you would use like [pre] VAR &_columns ;
[/pre]
Good Luck

PeterC
Ask a Question
Discussion stats
  • 2 replies
  • 146 views
  • 0 likes
  • 1 in conversation