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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

4 REPLIES 4
Patrick
Opal | Level 21

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.

Manu_SAS
Obsidian | Level 7

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

Patrick
Opal | Level 21

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.

Tom
Super User Tom
Super User

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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 1550 views
  • 5 likes
  • 3 in conversation