DATA Step, Macro, Functions and more

Procedure to run SAS macro

Reply
Occasional Contributor
Posts: 11

Procedure to run SAS macro

Hi there,

I'm new to SAS macro.

What is the correct way to run a SAS macro?

Do I first of all run the macro definition first?(highlight from %MACRO all the way to %MEND), then I go to the main program to call it?

OR

just call from the main program?

below is the code: (this is after an Excel file importation). Attached file is the Enterprise Guide file.

Thank you

Attachment
Super User
Super User
Posts: 6,502

Re: Procedure to run SAS macro

Your code looks fine other than that the data step is missing a RUN; statement to tell SAS that you are done typing the code.

Add a run statement after the last of the macro calls.

Occasional Contributor
Posts: 11

Re: Procedure to run SAS macro

thanks. I'm moving on

Super User
Posts: 10,514

Re: Procedure to run SAS macro

The macro defnition does need to be "compiled" before use. This is typically done by executing the definition code. However if a macro is not changing and is used frequently you may want to investigate a macro AUTOCALL LIBRARY. This is basically a folder or directory that SAS will look iin if you attempt to execute an unknown macro call to find a macro by that name an then compile as needed.

Occasional Contributor
Posts: 11

Re: Procedure to run SAS macro

thanks. I'm moving on. Will look into the autocall sometimes.

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