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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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