今回はLIBNAMEについて解説します。
ちなみにSAS Base Programmingでは、LIBNAMEができないと前半の記述問題が解けません。(データセットが与えられるので、割り当てられないとデータセットが見えないからです。)
SAS Base Programming 試験の流れを知りたい方は以下の記事を読んでください。
libname cert "/home/xxxxxxxxxx/cert/input";
![](https://how-to-business.com/wp-content/uploads/2021/11/30513dfce0a07d5f6966fb2d7f3c03c7-1024x443.png)
![](https://how-to-business.com/wp-content/uploads/2021/11/d4c68ea2cc8b69ddd5812d1bf21e92b9.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
libname cert "/home/xxxxxxxxxx/cert/input";
data cert.data1;
id1=1111;
run;
![](https://how-to-business.com/wp-content/uploads/2021/11/data1.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
- cert.data1として出力できる。
libname cert "/home/xxxxxxxxxx/cert/input";
data data2; set cert.data1;
run;
![](https://how-to-business.com/wp-content/uploads/2021/11/data1-1.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
- cert.data1として入力データセットとしている。
libname cert "/home/xxxxxxxxxx/cert/input";
libname cert clear;
![](https://how-to-business.com/wp-content/uploads/2021/11/clear1-1.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
- clearによって割り当てたcertを解除できる。
libname cert "/home/xxxxxxxxxx/cert/input";
data cert.data1;
id1=1111;
run;
data data2; set cert.data1;
run;
libname cert clear;
data data3; set cert.data1;
run;
![](https://how-to-business.com/wp-content/uploads/2021/11/clear2_1.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
- 割り当てている間は、cert.data1として出力できる。
- 割り当てている間は、cert.data1として入力データセットとしている。
- clearによって割り当てたcertを解除できる。
- 割り当てを解除すると、cert.data1として入力データセットにできない。
%let library = cert;
libname cert "/home/xxxxxxxxxx/cert/input";
data &library..data1;
id1=1111;
run;
![](https://how-to-business.com/wp-content/uploads/2021/11/4753e1d631c2a28dcd3e0ebecab352a1.png)
- libnameによって”/home/xxxxxxxxxx/cert/input”をcertライブラリに割り当てる。
- 割り当てている間は、cert.data1として出力できる。
- ライブラリ名をマクロ変数にしても展開できる。