As featured in:
Data Management Solutions Using SAS Hash Table Operations: A Business Intelligence Case Study
, and built from this
github repository
.
Chapter 10 Implementing a Hash Stack.sas
1
/* "Chapter 10 Implementing a Hash Stack.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 Demo_Stack (keep = Action PDV_Data Items) ;
7
dcl hash h (ordered:
"A"
) ;
8
h.defineKey (
"Key"
) ;
9
h.defineData (
"Key"
,
"Data"
) ;
10
h.definedone () ;
11
dcl hiter ih (
"h"
) ;
12
Data =
"A"
; link Push ;
13
Data =
"B"
; link Push ;
14
Data =
"C"
; link Push ;
15
link Pop ;
16
Data =
"D"
; link Push ;
17
Data =
"E"
; link Push ;
18
link Pop ;
19
link Pop ;
20
stop ;
21
Push: Key = h.num_items + 1 ;
22
h.add() ;
23
Action =
"Push"
;
24
link List ;
25
return ;
26
Pop: ih.last() ;
27
rc = ih.next() ;
28
h.remove() ;
29
Action =
"Pop"
;
30
link List ;
31
return ;
32
List: PDV_Data = Data ;
33
Items = put (
""
, $64.) ;
34
do
while
(ih.next() = 0) ;
35
Items = catx (
" "
, Items, cats (
"["
, Key,
","
, Data,
"]"
));
36
end ;
37
output ;
38
return ;
39
run ;
Generated by
For more information visit the
Bizarro Ball library
.