BookmarkSubscribeRSS Feed
Babloo
Rhodochrosite | Level 12

I've difficulties in understanding of using single quotes and double quotes in a macro. Also I would like to know usage of single ampersand and double ampersand as well. Ideally I wish to know the occasions where we tend to use double ampersand and single quotes and double quotes in a macro.

 

If someone can expalin it in simple terms I would be really grateful

 

Thanks in advance!

2 REPLIES 2
LinusH
Tourmaline | Level 20

These are the most basic features of SAS macro. There are tons of papers, documentation and samples.

If you wish to develop macro programming skill, consider to take some training.

 

In short, everything between single quotes is unaffected by macro logic - no symbolic substitution will take place.

Between double quotes, substitution can take place.

 

Double ampersand can be used if you wish to nestle macro variable names in each other - in other words, store dynamically a macro variable name in another macro variable, and then wish to substitute to the original macro variable value.

Data never sleeps
RW9
Diamond | Level 26 RW9
Diamond | Level 26

LinusH has kindly provided an explanation.  I would like to add that in my opinion if you are finding you have more than one & or % in a line of code then there is almost always a better way of doing things.  Simply restructuring your data, coding differently, or using functions removes the need for all lof it.  Remember easy to read code is maintable by other people.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 1093 views
  • 2 likes
  • 3 in conversation