How to sum elements of a specific row?

31 Views Asked by At

Hey guys I am trying to sum the values of the 100th row of a SAS data set ,I created using the randfun function this is the code i have ,am i doing something wrong?

Q1A=X[+,100];
print Q1A;

The log says ERROR: (execution) Invalid operand to operation.

1

There are 1 best solutions below

0
Richard On

To start with, that is not SAS syntax. With out seeing the data set you might want

  data want (label='Sum of X1-X<N> in 100th row');
    set have ;
    if _n_ = 100 then Q1A = sum(of x:) ;
  run ;

or

  data want (keep=Q1A label='Sum of X from 1st 100 rows') ;
    set have (obs=100) end=end ;
    Q1A + X ;
    if end ;
  run ;