BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Alkibiades
Obsidian | Level 7

I try to eport csv files in a DI Studio job using the file writer transformation. So far, so good. But when I try to have labels as a header instead of the variable names via entering label as a infile statement of the meta data object of the file, he still uses variables instead of labels as headers.

label.jpg

Am I missing an option to get labels instead of variable names?

1 ACCEPTED SOLUTION

Accepted Solutions
JosvanderVelden
SAS Super FREQ
@Cynthia_sas wrote some years ago
Hi:
If the SAS Utility macros are available to your DI Studio servers, then this macro %DS2CSV allows you to place labels in row 1 of the output file. For example:
[pre]
%ds2csv (data=sashelp.retail, runmode=b, csvfile=c:\temp\retail.csv,
labels=y, formats=y);
[/pre]

Documentation here:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002683390.htm

cynthia

View solution in original post

4 REPLIES 4
JosvanderVelden
SAS Super FREQ
@Cynthia_sas wrote some years ago
Hi:
If the SAS Utility macros are available to your DI Studio servers, then this macro %DS2CSV allows you to place labels in row 1 of the output file. For example:
[pre]
%ds2csv (data=sashelp.retail, runmode=b, csvfile=c:\temp\retail.csv,
labels=y, formats=y);
[/pre]

Documentation here:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a002683390.htm

cynthia
Patrick
Opal | Level 21

@Alkibiades 

"I try to eport csv files in a DI Studio job using the file writer transformation."

 

What you describe and show us doesn't add up. The screenshot you're showing us is from the File Reader. This transformation is used to read an external file (i.e. a .csv) into SAS. The File Writer is used to write a table to an external file.

 

Can you please clarify what exactly you're trying to achieve?

 

If it is about writing a SAS table to an external file (a .csv) and you want to use the SAS variable labels and not the SAS column names as column headers in the .csv then you will have to use custom code (user written node or reusable as a custom transformation) and using macro %ds2csv sounds like a good option to do so.

 

Should this really be about reading an external file into a SAS table using the File Reader transformation:

There is no LABEL option for the INFILE statement. Using DIS the column names and attributes created are based on your table metadata definition. That's what DIS will be using to generate the SAS code. If you want different column names then just change them in the table metadata definition.

Alkibiades
Obsidian | Level 7

The screenshot is actually the metadata object of the csv file, not the File Reader. The File Writer does not offer any real Option I could identify using labels.

Patrick
Opal | Level 21

@Alkibiades wrote:

The screenshot is actually the metadata object of the csv file, not the File Reader.

The File Writer does not offer any real Option I could identify using labels.


True. And yes, the file writer doesn't provide such an option so you will have to do your own thing.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1470 views
  • 3 likes
  • 3 in conversation