Single, Double, Triple Ampersand SAS Macro Variables

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

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

9 Responses to "Single, Double, Triple Ampersand SAS Macro Variables"

Next → ← Prev