---
title: コマンドプロンプト(Windows)
tags:  #[第6回大阪sas勉強会]  
author: [森岡裕[SASユーザー総会世話人]](https://www.docswell.com/user/6484025)
site: [Docswell](https://www.docswell.com/)
thumbnail: https://bcdn.docswell.com/page/PEXPKKDY7X.jpg?width=480
description: [第6回大阪sas勉強会]熊田　達哉
published: April 05, 24
canonical: https://www.docswell.com/s/6484025/57VXND-2024-04-05-151005
---
# Page. 1

![Page Image](https://bcdn.docswell.com/page/PEXPKKDY7X.jpg)

コマンドプロンプト
(Windows)
R2.1.31 アルケミックス 熊田 達哉


# Page. 2

![Page Image](https://bcdn.docswell.com/page/3EKD55X4JD.jpg)

ざっくりとOSの歴史
 OSなしの時代： マイクロコンピュータ(マイコン)
⇓
 DOS (Disk Operating System) ： MS-DOS 等
名前の通り、磁気ディスクが扱えるようになった
⇓
 Windows： 初期はMS-DOS上で動作していた
 このMS-DOSで使い始めたコマンドがコマンドプロンプト


# Page. 3

![Page Image](https://bcdn.docswell.com/page/L73RKK5DJ5.jpg)

コマンドプロンプトの使い方
 Windows 10では、検索画面枠に”cmd”と入力する


# Page. 4

![Page Image](https://bcdn.docswell.com/page/87DY33D27G.jpg)

コマンドプロンプト 全般的注意点
 UNCパスはカレントディレクトリとして使えない
ネットワークドライブレターを割り振って使用する(Y:等)
 カレントディレクトリを意識する
コマンドのデフォルトはカレントディレクトリ
上記例では、C:\Users\KUMA.ALCHEMICS
 命令やオプションはスペース区切りなので、ディレクトリを
設定する際はダブルクォーテーションで括る


# Page. 5

![Page Image](https://bcdn.docswell.com/page/VJP644XLE8.jpg)

リダイレクト 「&gt;」 「&lt;」
 入出力を変更すること
 標準入力：コンソール(キーボード)
ファイルからの入力 「&lt;」
例: SORT &lt;aaa.txt
 標準出力：ディスプレイ
ファイルへの出力 「&gt;」
ファイルへの追記 「&gt;&gt;」
例: DIR &gt;aaa.txt


# Page. 6

![Page Image](https://bcdn.docswell.com/page/2EV3XXL67Q.jpg)

パイプ 「|」
 命令の結果を別の命令に渡す
命令と命令の間に「|」を入力
例：TYPE aaa.txt | MORE
aaa.txtの内容をページ毎に表示する
DIR | CLIP
ディレクトリの内容をクリップボードに出力


# Page. 7

![Page Image](https://bcdn.docswell.com/page/57G3VVX2JL.jpg)

今でもよく使う命令１
 CHDIR(CD)
カレントディレクトリを変更する
例： CD C:\TEMP
 DIR, TREE
ディレクトリの内容を表示する
今でもValidation Documentの作成時に使用


# Page. 8

![Page Image](https://bcdn.docswell.com/page/4EQ56689JP.jpg)

今でもよく使う命令２
 FC

ファイルの比較

例：FC A.TXT B.TXT
 その他ネットワークに関するコマンドは、今でもよく使い
ますし、充実してきているように思います
ping, ipconfig, tracert, net, ・・・


# Page. 9

![Page Image](https://bcdn.docswell.com/page/KJ49449R71.jpg)

コマンドプロンプトとSASのやりとり(1)
 コマンドプロンプトとSASのやり取りは、テキストファイルで実
施するのが一般的と思われますが、クリップボードを介して
やり取りもできます。
options noxwait;
x &quot;DIR |CLIP&quot;;
filename _temp CLIPBRD;
data _TEXT;
length TXT $200.;
infile _temp dlm=&#039;09&#039;x;
input TXT;
run;


# Page. 10

![Page Image](https://bcdn.docswell.com/page/LE1K44KVJG.jpg)

コマンドプロンプトとSASのやりとり(1)
結果 (一部加工)
Obs TXT
1 ドライブ D のボリューム ラベルは ボリューム です
2 ボリューム シリアル番号は XXXX-XXXX です
3 D:\Users\xxxxx のディレクトリ
4 2020/01/23 13:41 &lt;DIR&gt;
.
5 2020/01/23 13:41 &lt;DIR&gt;
..
&lt;省略&gt;
16 2019/12/18 15:20
32,360 StdDiffPlot.png
17 2019/12/17 10:36
32,360 StdDiffPlot1.png
&lt;省略&gt;
25 2019/06/06 11:16 &lt;DIR&gt;
WINDOWS
26 8 個のファイル
132,284 バイト
27 14 個のディレクトリ 920,400,719,872 バイトの空き領域


# Page. 11

![Page Image](https://bcdn.docswell.com/page/GEWDXXD3J2.jpg)

コマンドプロンプトとSASのやりとり(2)
 スペース区切りで取得してみる
options noxwait;
x &quot;DIR |CLIP&quot;;
filename _temp CLIPBRD;
data _TEXT;
length TXT1-TXT4 $200.;
infile _temp dlm=‘ &#039;;
input TXT1-TXT4;
run;
proc print;
run;


# Page. 12

![Page Image](https://bcdn.docswell.com/page/47ZG66GGE3.jpg)

コマンドプロンプトとSASのやりとり(2)
結果 (一部加工)
Obs TXT1
TXT2
TXT3
TXT4
1 ドライブ
D
のボリューム
ラベルは
2 ボリューム
シリアル番号は XXXX-XXXX
です
3 D:\Users\xxx のディレクトリ
2020/01/23
13:41
4 2020/01/23
13:41
&lt;DIR&gt;
..
5 2019/06/06
11:15
&lt;DIR&gt;
Contacts
&lt;省略&gt;
16 2019/12/18
15:20
32,360
StdDiffPlot.png
17 2019/12/17
10:36
32,360
StdDiffPlot1.png
&lt;省略&gt;
24 2019/06/06
11:16
&lt;DIR&gt;
WINDOWS
25 8
個のファイル
132,284
バイト
26 14
個のディレクトリ 920,283,897,856 バイトの空き領域


