DATA Step, Macro, Functions and more

Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

Hello,

The source code of %ds2csv macro is stored in Application dispatcher.

In the following example, the %COPY statement writes the stored source code to the SAS log:

%macro foobar(arg) /store source

     des="This macro does not do much";

%put arg = &arg;

%mend

%copy foobar/source;

What If I'm using the Utility macro %DS2CSV, for example

%ds2csv (data=sashelp.retail, runmode=b, csvfile=.\retail.csv);

When I tried using below, im facing the following error,

%copy ds2csv/source;

ERROR: /source option is not included in the macro ds2csv.

When I tried to find the source code of %ds2csv,

DS2CSV CSV File

Generator

webcsv1.sas,

webcsv1.html

This sample program uses the DS2CSV macro to convert

any SAS data set to a comma separated variable file to be

downloaded to the browser


Accepted Solutions
Solution
‎02-10-2015 07:28 PM
Super User
Super User
Posts: 6,500

Re: Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

You need to use %COPY to view the source code of a macro if the macro was delivered in a compiled catalog.  But DS2CSV and other supplied SAS macro are delivered as source files. 

So you don't need to se %COPY, just read the file.

data _null_;

  infile sasautos('ds2csv.sas');

  input;

  put _infile_;

run;

View solution in original post


All Replies
Respected Advisor
Posts: 3,894

Re: Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

There are different options when compiling a macro SAS(R) 9.4 Macro Language: Reference, Third Edition

Using "source" will store the source code with the compiled macro so it can easily be retrieved. On the other hand using "secure" will make it almost impossible for you to retrieve the source code.

Contributor
Posts: 20

Re: Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

Hi Patrick,

Thanks for the reply.

Alternatively, went through the SASROOT directory(Unix SAS 9.4). Under SASAUTOS, we have the ds2csv.sas code. Copied to my home directory, modified by adding "/store source" in %macro statement.

Thus, ERROR resolved.

Thanks,

Manohar

Respected Advisor
Posts: 3,894

Re: Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

If you want this as a permanent solution for everybody then you could also extend the SASAUTOS paths with an additional directory (as first directory) and then store the amended copy of ds2csv.sas there. SAS will then pick-up this "overlay" version as it finds it first.

The disadvantage of such an approach is of course that this macro will never get updated when upgrading to a newer SAS version.

Solution
‎02-10-2015 07:28 PM
Super User
Super User
Posts: 6,500

Re: Is there any way to store the source code of SAS Utility Macro(%DS2CSV)

You need to use %COPY to view the source code of a macro if the macro was delivered in a compiled catalog.  But DS2CSV and other supplied SAS macro are delivered as source files. 

So you don't need to se %COPY, just read the file.

data _null_;

  infile sasautos('ds2csv.sas');

  input;

  put _infile_;

run;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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