As featured in:
Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study
, and built from this
github repository
.
Chapter 4 Keynumerate Loop Style2 Snippet.sas
1
/* "Chapter 4 Keynumerate Loop Style2 Snippet.sas" from the SAS Press book
2
Data Management Solutions Using SAS Hash Table Operations:
3
A Business Intelligence Case Study
4
*/
5
6
data _null_ ;
7
dcl hash H (multidata:
"Y"
, ordered:
"N"
) ;
8
H.definekey (
"K"
) ;
9
H.definedata (
"D"
) ;
10
H.definedone () ;
11
do
K = 1, 2, 2, 3, 3, 3 ;
12
q + 1 ;
13
D = char (
"ABCDEF"
, q) ;
14
H.ADD() ;
15
end ;
16
h.output(dataset:
"AsLoaded"
) ;
17
call missing (K, D, RC) ;
18
put
"Before Enumeration:"
;
19
put +3 (RC K D) (=) ;
20
put
"During Enumeration:"
;
21
do
RC = H.FIND(KEY:3) BY 0
while
(RC = 0) ;
22
put +3 (RC K D) (=) ;
23
RC = H.FIND_NEXT() ;
24
end ;
25
put
"After Enumeration:"
;
26
put +3 (RC K D) (=) ;
27
stop ;
28
run ;
Generated by
For more information visit the
Bizarro Ball library
.