How to get a macro file into SAS

Reply
New Contributor
Posts: 2

How to get a macro file into SAS

Hi,

I am a new user. I have a macro saved on my desktop. How to get in into Sas? It shoul be in the current working library, but somehow I cannot get it done..

Super Contributor
Posts: 644

Re: How to get a macro file into SAS

Having a SAS macro on your desktop is an unusual practice.  I suggest you talk to whoever put it there and ask how you are expected to use it.

On the off chance that you put the macro there yourself, does the file end with the suffix ".sas"?  If so, it is probably the source code for the macro and you can double click it to start SAS and run the macro code.  This will compile the macro cade and if the source file also includes an invocation of the macro, it should run.  The macro source will appear in your program editor, the compiled macro sits in a special catalog in your work library.  Otherwise you can open the code from the SAS session editor and run it from there.

If this macro is compiled code you won't be able to use it until it is registered in your SAS session.  The easiest way to do this is to run the uncompiled source code.

If none of this advice sfits your situation you need to tell us exactly what you have and why it is there.

Richard

New Contributor
Posts: 2

Re: How to get a macro file into SAS

Dear Ricahrd,

Thank you for your advice. I downloaded the macro myself from http://www.mcw.edu/biostatistics/statisticalresources/CollaborativeSoftware.htm

I was following the instructions given in the paper by Zu Zhang , in which they provide a macro for making adjusted survival curves in SAS. In the paper, it is instructed that one should copy the macro in the current working SAS directory(which I cannot do, it might be simple thing but I cannot get it done).

Then they instruct to invoke the macro by the following commands:

%INCLUDE 'ADJSURV.sas';

%ADJSURV (inputdata, time, group, covariates, model, outdata);

Yes, the macro saved on my desktop has an extension .sas. I even tried to invoke it by putting the path as suggested on the internet, but it does not work.

Super User
Posts: 17,829

Re: How to get a macro file into SAS

The %include should have the full path to the file, regardless of where it is.

%include 'path to the file as you would in network directory';

%include 'C:\users\saira\desktop\adjsurv.sas';

You can also open the macro code in SAS and run it directly and then use the second line of code.

Super User
Super User
Posts: 6,500

Re: How to get a macro file into SAS

Are you using PC SAS or are you using Enterprise Guide with SAS executing on a different machine?

Either way why not just add the source code for the macro definition into the top of your program, right before the macro call.

Ask a Question
Discussion stats
  • 4 replies
  • 287 views
  • 0 likes
  • 4 in conversation