今回はマクロ変数の&&について解説していきます。
(参考:%PUT 【SAS】%PUTステートメントは文字列をログに出力する。その1 | ビジネスイッチ (how-to-business.com))
比較の為、まずは通常のマクロ変数を記載します。
/* & */
%let yyyymm_1 = 202301;
%put &yyyymm_1.;
![](https://how-to-business.com/wp-content/uploads/2023/05/1.png)
- &yyyymm_1.を展開して202301とする。
続いて、&&を用いたパターン
/* && */
%let yyyymm_1 = 202301;
%let num = 1;
%put &num.;
%put &&yyyymm_&num..;
![](https://how-to-business.com/wp-content/uploads/2023/05/1-1.png)
&&の役割としては、以下の2つ。
- &&を一旦スルーして次に出てくる&~.を展開する。
- 1の終了後、&&⇒&と読み替えて扱う。
動きを解説すると以下の様になります。
![](https://how-to-business.com/wp-content/uploads/2023/05/5621deba8a18b839c7a4321764bb05e8-1024x576.jpg)
![](https://how-to-business.com/wp-content/uploads/2023/05/2a831ec055ed4fee4e1d0936ea40500d-1024x576.jpg)
![](https://how-to-business.com/wp-content/uploads/2023/05/ee3be1d100caf1aa771552d59c2bd436-1024x576.jpg)
![](https://how-to-business.com/wp-content/uploads/2023/05/5f63f49b6b7d98988e1002a4a4f2d6d5-1024x576.jpg)
![](https://how-to-business.com/wp-content/uploads/2023/05/04f86ea9c104d100d663feb8a9a65769-1024x576.jpg)
![](https://how-to-business.com/wp-content/uploads/2023/05/63ead695680eb0c485fa3f134844052f-1024x576.jpg)