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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 546 views
  • 1 like
  • 2 in conversation