1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

SAS 変数定義 dataステップ

Last updated at Posted at 2020-06-11

SASの変数定義についてのメモ
変数の型や変数長、フォーマット等を指定できる

SQLプロシジャなどでも変数の型や変数長、フォーマット等を指定できるが、ここではdataステップでの方法を紹介する

attribステートメント

length,label,formatなどを同時に指定可能

data xxx;
  attrib
    変数1 length = $10 label = "aaaaa"
    変数2 length = $20 label = "bbbbb"
    変数3 length = 8
    変数4 length = 8   format = time5.
    変数5 length = 8   label = "eeeee" format = yymmdd10.
  ;
...
run;

などと指定

lengthステートメント

文字数値の設定や長さの設定するだけなら、こっちの方が楽

data xxx;
length 変数1 8 変数2 $50;
...
run;

で、変数1は数値変数、変数2は長さ20の文字変数

arrayステートメント

配列定義のときに、新規変数を定義可能

data xxx;
array AAA[10] $1111 VAR1 - VAR10;
...
run;

など

変数の順番だけ変えたいときは

data xxx;
  format 変数1 変数2 ...;
  set xxx;
run;

https://support.sas.com/documentation/cdl_alternate/ja/lestmtsref/68024/HTML/default/n1wxb7p9jkxycin16lz2db7idbnt.htm
https://support.sas.com/documentation/cdl_alternate/ja/lestmtsref/68024/HTML/default/p08do6szetrxe2n136ush727sbuo.htm

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?