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

Hello team,

What does %macro varlist() do?

Regards,

Blue Blue

Blue Blue
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

It starts the definition of a macro named Varlist.

The code between that statement and %mend; comprise the entire definition of a macro.

 

If there is no corresponding %mend; following and the code is executed you may place the SAS system into an unstable state depending on what you do as SAS is expecting an "%mend;" somewhere.

 

SAS macros are one way to generate other code or perform coded actions. Typically the () should contain parameter values that the code uses to generate different code. The code between %macro and %mend is only the definition and executing the code makes the compiled macro available for later use. To use the macro you would submit %varlist () . This tells SAS that you want to execute the code that the macro varlist defined.

 

Macro code is not a trivial exercise but not horrific either. But the more familiarity you have with SAS in general the more likely you can write a useful macro that actually works properly.

View solution in original post

2 REPLIES 2
ballardw
Super User

It starts the definition of a macro named Varlist.

The code between that statement and %mend; comprise the entire definition of a macro.

 

If there is no corresponding %mend; following and the code is executed you may place the SAS system into an unstable state depending on what you do as SAS is expecting an "%mend;" somewhere.

 

SAS macros are one way to generate other code or perform coded actions. Typically the () should contain parameter values that the code uses to generate different code. The code between %macro and %mend is only the definition and executing the code makes the compiled macro available for later use. To use the macro you would submit %varlist () . This tells SAS that you want to execute the code that the macro varlist defined.

 

Macro code is not a trivial exercise but not horrific either. But the more familiarity you have with SAS in general the more likely you can write a useful macro that actually works properly.

GN0001
Barite | Level 11
It has a %Mend, I didn't put it on my first post.
Thanks for the response.
Blue Blue
Blue Blue

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 912 views
  • 1 like
  • 2 in conversation