sum関数 sum(0,of )

Last-modified: 2013-08-27 (火) 12:52:23

sum関数などを使うときにおいて,
引数が多かったり,数が明確でないなので ofを使うときにおいて,
欠損をゼロにさせるために,定数0を引数に加えたいときにおいて,
わざわざゼロの値をもつ変数を定義せずにささっとコーディングしたいのならば..

sum(0,of ...)

と書くとよい

data x;
  g1=1;
  g2=2;
  g3=3;
  a10=.;
  a11=.;

  total=sum(0,g1,g2,g3,a10,a11);
  put total=;

  total=sum(0,of g1-g3);
  *total=sum(of 0 g1-g3);/*これはだめ*/
  *zero=0;*total=sum(of zero g1-g3);/*これはいいけどいまいち*/
  put total=;

  total=sum(0,of g1--a11);
  put total=;

  total=sum(0,of g: a:);
  put total=;

  total=sum(0,of a:);
  put total=;

run;

/*
total=6
total=6
total=6
total=6
total=0 */