# Single, Double, Triple Ampersand SAS Macro Variables

#### Live Online Training :SAS Programming with 50+ Case Studies - Explain Programming Concepts in Simple English - Live Projects - Scenario Based Questions - Job Placement Assistance - Get 10% off till Sept 25, 2017 - Batch starts from October 8, 2017

This tutorial explains how single (&), double (&&) and Triple (&&&) ampersand macro variables are resolved.

Example
%let x=temp;
%let n=3;
%let x3=result;
%let temp3 = result2;
Check how multiple ampersand macro variables work -
%put &x&n;
%put &&x&n;
%put &&&x&n;
Rule :

The scanner reads from left to right.
1. &x&n    : Macro variable X resolves first to temp and then N resolves to 3.   Output : temp3
2. &&x&n : Two ampersands (&&) resolves to one ampersand (&) and scanner continues and then N resolves to 3 and then &x3 resolves to result. Output : result
3. &&&x&n :  First two ampersands (&&) resolves to & and then X resolves to temp and then N resolves to 3. In last, &temp3 resolves to result2. Output : result2
 Ampersand Macro Variables

#### SAS Tutorials :100 Free SAS Tutorials

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has close to 7 years of experience in data science and predictive modeling. During his tenure, he has worked with global clients in various domains like retail and commercial banking, Telecom, HR and Automotive.

While I love having friends who agree, I only learn from those who don't.

Let's Get Connected: Email | LinkedIn

### 10 Responses to "Single, Double, Triple Ampersand SAS Macro Variables"

1. good explantation

1. Thank you for stopping by my blog!

2. nice explanation

1. Thank you for your feedback.

3. Very well Explained..Thanks.

4. well explained...thank you

5. Great explanation (Y)

6. Great explanation (Y)

7. Great stuff...keep posting

8. Very good stuff, really helps me a lot! Thank you very much!

Next → ← Prev