Hash tables are a new data structure in SAS 9.
This sample runs in SAS 9.2 phase 1 and later
The size and composition of the hash table is determined at execution time.
The entire hash table should fit into *real* memory. If the hash table is too large, paging will start and cause performance to deteriorate significantly.
Reasons to use a hash table:
The full code is in the "Downloads" tab.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
These sample files and code examples are provided by SAS Institute Inc. "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. Recipients acknowledge and agree that SAS Institute shall not be liable for any damages whatsoever arising out of their use of this material. In addition, SAS Institute will provide no support for the materials contained herein.
1 /* hashsize.sas */ 2 3 options fullstimer msglevel=i nosource; 152 153 /* remove the asterisk in front of the macro call you want to run 153! */ 154 155 /* 3K rows, 1 key variable, $4, 2 data variables, 1 numeric, 1 $10 155! */ 156 %hash_test (rows=3000,keycnt=1,datacnt=2, 157 K1LEN=4,K1TYP=C, 158 d1len=8,d1typ=n,d2len=10,d2typ=c); run; ROWS=3000 KEYCNT=1 DATACNT=2 K1LEN=4 K1TYP=C D1LEN=8 D1TYP=N D2LEN=10 D2TYP=C XMLRMEM available = 1,248,723,968 Actual table size: 144,000 bytes Row size: 48 bytes Optimal HASHEXP: 12 159 /* 30K rows, 3 key variables, numeric, no data variables */ 160 %hash_test(rows=30000,keycnt=3, 161 k1len=8,k1typ=n, 162 k2len=8,k2typ=n, 163 k3len=8,k3typ=n, 164 datacnt=0 165 ) ; run; ROWS=30000 KEYCNT=3 K1LEN=8 K1TYP=N K2LEN=8 K2TYP=N K3LEN=8 K3TYP=N DATACNT=0 XMLRMEM available = 1,248,723,968 Actual table size: 1,920,000 bytes Row size: 64 bytes Optimal HASHEXP: 15 166 /* 30K rows, 3 key variables, numeric, 1 data variable, $1 */ 167 %hash_test(rows=30000,keycnt=3, 168 k1len=8,k1typ=n, 169 k2len=8,k2typ=n, 170 k3len=8,k3typ=n, 171 datacnt=1,d1len=1,d1typ=c 172 ) ; run; ROWS=30000 KEYCNT=3 K1LEN=8 K1TYP=N K2LEN=8 K2TYP=N K3LEN=8 K3TYP=N DATACNT=1 D1LEN=1 D1TYP=C XMLRMEM available = 1,248,723,968 Actual table size: 1,440,000 bytes Row size: 48 bytes Optimal HASHEXP: 15 173 /* 5K rows, 1 key variable, numeric, 1 data variable, $84 */ 174 %hash_test(rows=5000,keycnt=1, 175 k1len=8,k1typ=n, 176 datacnt=1,d1len=84,d1typ=c 177 ) ; run; ROWS=5000 KEYCNT=1 K1LEN=8 K1TYP=N DATACNT=1 D1LEN=84 D1TYP=C XMLRMEM available = 1,248,723,968 Actual table size: 560,000 bytes Row size: 112 bytes Optimal HASHEXP: 13
The code below defines a macro that can be used to build a hash table containing key and data variables of the size and type needed for your program. You can specify the expected number of rows for the hash table.
The macro creates a DATA step that shows the amount of memory available before the DATA step starts, along with the size of the table, the size of each row and an optimal HASHEXP value.
There are example macro calls at the bottom of the macro definition. Change one of the execution to reflect the attributes of your hash table.
Download macro and test executionsType: | Sample |
Date Modified: | 2008-12-22 15:02:05 |
Date Created: | 2008-12-12 16:01:23 |
Product Family | Product | Host | SAS Release | |
Starting | Ending | |||
SAS System | Base SAS | z/OS | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |||
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |||
Microsoft® Windows® for x64 | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |||
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |||
Microsoft Windows XP Professional | 9.2 TS1M0 | |||
Windows Vista | 9.2 TS1M0 | |||
64-bit Enabled AIX | 9.2 TS1M0 | |||
64-bit Enabled HP-UX | 9.2 TS1M0 | |||
64-bit Enabled Solaris | 9.2 TS1M0 | |||
HP-UX IPF | 9.2 TS1M0 | |||
Linux | 9.2 TS1M0 | |||
Linux for x64 | 9.2 TS1M0 | |||
OpenVMS on HP Integrity | 9.2 TS1M0 | |||
Solaris for x64 | 9.2 TS1M0 |