@ursula wrote:
Actually I want it run in data steps. but it seems like not recommended.
The reason that including a Total or other summary value in the same variable is that if you don't use the data set for awhile and you forget the total is there, or some else uses it without knowledge may run code such as:
proc means data=<that data set> mean=;
var c1 - c30;
run;
Which would include the TOTAL into the calculation for the means. Which would yield very bad results.
And even if you do know the total is there, you need to do modifications to the code to exclude it.
Generally such things are needed by PEOPLE, not computer programs. When a routine, such as regression, needs such a statistic it will calculate it as needed from the data (and again, if a total is there throw of the calculations).
Use a report procedure such as Proc Print, Report or Tabulate which will calculate totals without modifying your data, unless you know that a further computation in the process needs that total as the same variable.
I might create a summary value in a data set if I need to create an obnoxious complicated report layout, but I would also place that into a different variable to prevent accidental misuse.
... View more