Difference between total = sum(of q1-q4) and total = sum(q1-q4) in SAS
Sophia Terry
Made a dummy data :
data dummy;
input q1 q3 q4 q2 q6$ bu$ q5;
cards;
1 2 3 5 sa an 3
2 4 3 6 sm sa 4
6 5 3 8 cb na 3
;
run;
data test1(drop=q1--q5);
set dummy;
total = sum(of q1-q4);
total1 = sum(of q1--q4);
proc print data=test1;
run;if I change the total = sum(of q1-q4); to total = sum(q1-q4); the output changes. How are the two different? And how are they calculated?
1 Answer
- sum(of q1-q4) means sum(q1, q2, q3, q4).
- sum(of q1--q4) means sum of all numeric variables that are placed between q1 and q4 (included) in the PDV.
- sum(q1-q4) is different. In this case - is a minus sign. In your first obs, that means total = sum(q1-q4) = sum(1-3) = sum(-2) = -2.