The sashash package provides powerful and efficient hash-based lookup and validation tools specifically designed for SAS programming. Leveraging the robust capabilities of SAS hash objects, this package enables rapid and dynamic key-based data retrieval and existence checking directly within a single data step. This significantly reduces the need for separate sort and merge steps, streamlining workflows and enhancing performance.

Enables efficient and dynamic retrieval of variables from a specified master dataset based on provided keys, directly within a single data step without separate sorting or merging.
PARAMETERS:
master : (Required) Name of the master dataset to lookup from.
key : (Required) Space-separated list of key variables for the lookup.
var : (Required) Space-separated list of variables to retrieve from the master dataset. Default is none.
wh : (Optional) SQL WHERE clause condition to subset the master dataset before loading into hash table. Default is none.
warn : (Optional) Y/N flag. If 'Y', issues a warning in the log when the lookup key is not found. Default is 'N'.
dropviewflg: (Optional) Y/N flag. If 'Y', drops temporary SQL view created when the 'wh' parameter is used. Default is 'Y'.
Usage Example:
data a;
set b;
%kvlookup(master=sashelp.class,
key=Name,
var=Age Sex,
wh= %nrbquote(Age > 12),
warn=Y,
dropviewflg=Y);
run;
Dynamically validates the existence of keys within a master dataset directly within a single data step. Ideal for rapid data integrity checks and immediate flagging of key existence or non-existence.
PARAMETERS:
master : (Required) Name of the master dataset to check against.
key : (Required) Space-separated list of key variables to check.
wh : (Optional) SQL WHERE clause condition to subset the master dataset before loading into hash table. Default is none.
fl : (Required) Name of the output variable indicating existence.
cat : (Optional) Controls output format of existence indicator:
- 'YN' (default): Returns 'Y' if key exists, 'N' otherwise.
- 'NUM': Returns 1 if key exists, 0 otherwise.
dropviewflg: (Optional) Y/N flag. If 'Y', drops temporary SQL view created when the 'wh' parameter is used. Default is 'Y'.
Usage Example:
data a;
set b;
%keycheck(master=sashelp.class,
key=Name,
wh= %nrbquote(Age >= 15),
fl=exist_flag,
cat=YN,
dropviewflg=Y);
run;
General-purpose duplicate key checker using SAS hash objects.
Parameters:
key : One or more key variables used to detect duplicates (space-delimited).
Usage Example:
data a;
set sashelp.class;
%kduppchk(AGE SEX);
%kduppchk(NAME);
run;

0.0.2(23July2025): first stable version
0.0.1(22April2025): Initial version
The package is built on top of SAS Packages framework(SPF) developed by Bartosz Jablonski.
For more information about SAS Packages framework, see SAS_PACKAGES.
You can also find more SAS Packages(SASPACs) in SASPAC.
Firstly, create directory for your packages and assign a fileref to it.
filename packages "\path\to\your\packages";
Secondly, enable the SAS Packages Framework.
(If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)
%include packages(SPFinit.sas)
Install SAS package you want to use using %installPackage() in SPFinit.sas.
%installPackage(packagename, sourcePath=\github\path\for\packagename)
(e.g. %installPackage(ABC, sourcePath=https://github.com/XXXXX/ABC/raw/main/))
Load SAS package you want to use using %loadPackage() in SPFinit.sas.
%loadPackage(packagename)