Hash and Hash Iterator Object Language Elements |
Applies to: | Hash object |
Syntax | |
Arguments | |
Details | |
Comparisons | |
Examples | |
See Also |
Syntax |
rc=object.SUM(SUM: variable-name); |
specifies whether the method succeeded or failed.
A return code of zero indicates success; a nonzero value indicates failure. If you do not supply a return code variable for the method call and the method fails, then an appropriate error message is written to the log.
specifies the name of the hash object.
specifies a DATA step variable that stores the current summary value of a given key.
Details |
You use the SUM method to retrieve key summaries from the hash object. For more information, see Maintaining Key Summaries in SAS Language Reference: Concepts.
Comparisons |
The SUM method retrieves the summary value for a given key when only one data item exists per key. The SUMDUP method retrieves the summary value for the current data item of the current key when more than one data item exists for a key.
Examples |
The following example uses the SUM method to retrieve the key summary for each given key, K=99 and K=100.
k = 99; count = 1; h.add(); /* key=99 summary is now 1 */ k = 100; h.add(); /* key=100 summary is now 1 */ k = 99; h.find(); /* key=99 summary is now 2 */ count = 2; h.find(); /* key=99 summary is now 4 */ k = 100; h.find(); /* key=100 summary is now 3 */ h.sum(sum: total); put 'total for key 100 = ' total; k = 99; h.sum(sum:total); put 'total for key 99 = ' total; run;
The first PUT statement prints the summary for k=100:
total for key 100 = 3
The second PUT statement prints the summary for k=99:
total for key 99 = 4
See Also |
Methods: | |||||||||||
Operators: | |||||||||||
Statements: |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.