Method
|
Description
|
Syntax
|
---|---|---|
ADD
|
Adds the specified data
that is associated with the given key to the hash object.
|
object-name.ADD( )
|
DEFINEDATA
|
Defines data to be stored
in the hash object.
|
object-name.DEFINEDATA( )
|
DEFINEDONE
|
Specifies that all key
and data definitions are complete.
|
object-name.DEFINEDONE( )
|
DEFINEKEY
|
Defines key components
to the hash object.
|
object-name.DEFINEKEY( )
|
FIND
|
Determines whether the
key is stored in the hash object.
|
object-name.FIND( )
|
OUTPUT
|
Creates one or more
data sets containing the data in the hash object.
|
object-name.OUTPUT( )
|
data work.report; if 0 then set certadv.ctcities (keep=Code City Name); if _N_=1 then do; /*1*/ declare hash airports (dataset: "certadv.ctcities"); /*2*/ airports.definekey ("Code"); /*3*/ airports.definedata ("City", "Name"); /*4*/ airports.definedone(); /*5*/ end;
1 | When _N_ is equal to 1, the code declares and defines the hash object only for the first DATA step iteration. This statement is never executed, but it makes a place in the PDV for every column that is in the table. Without this logic, the statements that are associated with the hash object are all executable. Hash object memory is not released and reused each time. You can potentially run out of memory if you have a lot of data to load into the hash object. |
2 | The DECLARE statement declares a hash object named Airports. The DATASET argument refers to the Certadv.CtCities data set that contains the values to be loaded. |
3 | The DEFINEKEY method defines Code as the key component. |
4 | The DEFINEDATA method defines City and Name as the data components. |
5 | The DEFINEDONE method loads the Certadv.CtCities data set into the hash object. |
Key: Code
|
Data: City
|
Data: Name
|
---|---|---|
ANC
|
Anchorage, AK
|
Anchorage International
Airport
|
BNA
|
Nashville, TN
|
Nashville International
Airport
|
CDG
|
Paris
|
Charles de Gaulle
|
LAX
|
Los Angeles, CA
|
Los Angeles International
Airport
|
RDU
|
Raleigh-Durham, NC
|
Raleigh-Durham International
Airport
|