BookmarkSubscribeRSS Feed
Sathya3
Obsidian | Level 7
%let out=/sas/output/file_name.csv;

filename dest hadoop "&out";

%ds2csv(data=input_table,labels=N,runmode=b,csvfile=out);

 

I have to create a csv file from dataset by only using ds2csv

log shows csv successfully generated but I am not able to find it in specified hadoop destination folder.

macro variable out is getting resolved correctly

 

should i not give csvfile=libref in ds2csv utility. What is the issue? 

6 REPLIES 6
Amir
PROC Star

Hi,

 

Have you tried using dest as your last argument, e.g.:

 

%ds2csv(data=input_table,labels=N,runmode=b,csvfile=dest);

If this does not help then please share the log.

 

 

Thanks & kind regards,

Amir.

 

Edit: Replaced out with dest.

Sathya3
Obsidian | Level 7
There is a small typing mistake in the code I have posted.

csvfile=dest in ds2csv
( not csvfile=out)
Amir
PROC Star

Hi,

 

Try using another parameter csvfref=dest (in place of csvfile=dest):

 

%ds2csv(data=input_table,labels=N,runmode=b,csvfref=dest);

 

 

Thanks & kind regards,

Amir.

Tom
Super User Tom
Super User

Can you write to the HADOOP area just using a simple a data step?   For example try making a file with 3 columns and one row of data.

data _null_;
  file dest dsd;
  put 'a,b,c';
  put '1,2,3';
run;

If so then the issue is how %DS2CSV() is writing the file.

 

Can you just use PROC EXPORT instead to write the CSV file to HADOOP?

proc export data=input_table file=dest dbms=csv;
run;
Kurt_Bremser
Super User

You must use the correct macro variable reference:

%ds2csv(data=input_table,labels=N,runmode=b,csvfile=&out.)

The documentation of the macro can be found here 

Tom
Super User Tom
Super User

@Kurt_Bremser wrote:

You must use the correct macro variable reference:

%ds2csv(data=input_table,labels=N,runmode=b,csvfile=&out.)

The documentation of the macro can be found here 


So that document say:

 

csvfile=external-filename

specifies the name of the CSV file where the formatted output is to be written. If the file that you specify does not exist, then it is created for you.

Note Do not use the CSVFILE argument if you use the CSVFREF argument.

csvfref=fileref

specifies the SAS fileref that points to the location of the CSV file where the formatted output is to be written. If the file that you specify does not exist, then it is created for you.

Note Do not use the CSVFREF argument if you use the CSVFILE argument.

 

So if they want to use the fileref DEST to write to HADOOP that was defined using the &OUT macro then they need to use CSVFREF parameter instead of CSVFILE parameter.

%ds2scv(...csvfref=dest)

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 914 views
  • 0 likes
  • 4 in conversation