Hash and Hash Iterator Object Language Elements |
Applies to: | Hash object |
Syntax | |
Arguments | |
Details | |
Examples |
Syntax |
variable_name=object.ITEM_SIZE; |
specifies name of the variable that contains the size of the item in the hash object.
specifies the name of the hash object.
Details |
The ITEM_SIZE attribute returns the size (in bytes) of an item, which includes the key and data variables and some additional internal information. You can set an estimate of how much memory the hash object is using with the ITEM_SIZE and NUM_ITEMS attributes. The ITEM_SIZE attribute does not reflect the initial overhead that the hash object requires, nor does it take into account any necessary internal alignments. Therefore, the use of ITEM_SIZE does not provide exact memory usage, but it does return a good approximation.
Examples |
The following example uses ITEM_SIZE to return the size of the item in MYHASH:
data work.stock; input prod $1-10 qty 12-14; datalines; broccoli 345 corn 389 potato 993 onion 730 ; data _null_; if _N_ = 1 then do; length prod $10; /* Declare hash object and read STOCK data set as ordered */ declare hash myhash(dataset: "work.stock"); /* Define key and data variables */ myhash.defineKey('prod'); myhash.defineData('qty'); myhash.defineDone(); end; /* Add a key and data value to the hash object */ prod = 'celery'; qty = 183; rc = myhash.add(); /* Use ITEM_SIZE to return the size of the item in hash object */ itemsize = myhash.item_size; put itemsize=; run;
The following lines are written to the log:
itemsize=40
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.