BookmarkSubscribeRSS Feed
SeekYourWay
Calcite | Level 5

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

4 REPLIES 4
Tom
Super User Tom
Super User

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.

SeekYourWay
Calcite | Level 5

thanks. I'm moving on

ballardw
Super User

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.

SeekYourWay
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 788 views
  • 0 likes
  • 3 in conversation