/***************************************************************************************************************** SAS file name: pdv_variables_hash.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to use the hash object to write all PDV variables to a SAS data set. Author: Peter Clemmensen Creation Date: 08/02/2021 This program supports the blog post "An interesting PDV Application of the SAS Hash Object" on SASnrd.com *****************************************************************************************************************/ options validvarname = any; proc sort data = sashelp.class out = class; by sex age name; run; data _null_; if _N_ = 1 then do; length _pdvname_ $64; declare hash pdvhash(ordered : "Y"); pdvhash.definekey("_N_"); do while (1); call vnext(_pdvname_); if missing(_pdvname_) then leave; if _pdvname_ = "_pdvname_" then continue; pdvhash.definedata(_pdvname_); end; pdvhash.definedone(); end; set class(in = inClass) end = end nobs = nobs; by sex age name; array a sex; pdvhash.add(); if end then do; pdvhash.output(dataset : "AllVarsInPDV"); stop; end; run;