0
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?

SAS言語のデータセットにおけるヌル値

Last updated at Posted at 2025-03-19

読み込んだデータセット内に欠損値が存在することはよくあります。今回はヌル値を含んだデータセットを作成した上でその検出を行います。SAS言語上、ヌル値は.(ピリオド)で表されます。

data example;
  input Name $ Age Height;
  datalines;
John 15 5.5
Mary . 5.7    /* Ageにヌル値 */
James 14 .
Sophia . .    /* AgeとHeightにヌル値 */
;
run;
proc print data=example;
  title 'Original Data with Missing Values';
run;
data check_missing;
  set example;
  /* AgeまたはHeightにヌル値がある場合に検出 */
  if missing(Age) then do;
    Missing_Age = 'Yes';
  end;
  else do;
    Missing_Age = 'No';
  end;
  if missing(Height) then do;
    Missing_Height = 'Yes';
  end;
  else do;
    Missing_Height = 'No';
  end;
run;
proc print data=check_missing;
  title 'Data with Missing Values Detection';
run;

出力結果:
result1



SAS初心者のとき困ったところ戸惑ったところ | Tech Blog | CRESCO Tech Blog に載っていた情報なのですが、ヌル値は -♾️ 扱いになるとのことです。ヌル値と -♾️ を比較してみます。

data example;
  input Name $ Age Height;
  datalines;
John 15 5.5
Mary . 5.7    /* Ageにヌル値 */
James 14 .
Sophia . .    /* AgeとHeightにヌル値 */
;
run;

data check_null_is_minus_inf;
  set example;
  /* AgeまたはHeightにヌル値がある場合に検出 */
  if Age=-INF then do;
    null_is_minus_inf = 'Yes';
  end;
  else do;
    null_is_minus_inf = 'No';
  end;

run;

proc print data=check_null_is_minus_inf;
run;

出力結果:
result2



SAS言語の実行環境

SAS言語の動作環境はAltair SLC 及び Altair Analytics Workbenchを使用しております。詳細や最新情報はAltair公式サイトをご覧ください。

動作確認を行なった環境

  • MacBookPro(2020 M1)
    • RAM 16GB
    • macOS Sonoma 14.4.1
  • Altair SLC 2024 (05.24.03.00.001528)
  • Altair Analytics Workbench 5.24.3.0.1528-GA-release-2024.2
0
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
0
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?