BookmarkSubscribeRSS Feed
clqa
Calcite | Level 5

why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?

Screen Shot 2018-09-21 at 9.48.12 AM.png

4 REPLIES 4
PaigeMiller
Diamond | Level 26

In this trivial example, the macro variable does nothing that you couldn't do better without the macro variable.

 

In other examples, macro variables allow code to be dynamic, and change as needed without the human programmer having to re-write or re-code large portions of text.

--
Paige Miller
data_null__
Jade | Level 19

@clqa wrote:

why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?

 

The purpose of macro variables is character substitution. 

bobpep212
Quartz | Level 8
Think about a bigger program where you have to reference age in lots of places. In this example, it references age in 2 spots. Using a macro variable instead means if you need to change the age, you only need to do it in one location. It also prevents you from accidentally not updating the age in one of the locations in your code.
Reeza
Super User

 

 

There is always more than one way to do something. 

What happens when you want to do it for each age in the data?

 

@clqa wrote:

why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?

Screen Shot 2018-09-21 at 9.48.12 AM.png


 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 879 views
  • 2 likes
  • 5 in conversation