/***************************************************************************************************************** SAS file name: Array_Functions.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate 8 functions that accept lists of variables as arguments. Author: Peter CLemmensen Creation Date: 01May2019 This program supports the blog post "8 SAS Array Functions You Should Know" on SASnrd.com *****************************************************************************************************************/ /* Example Data */ data have; input n1-n5 (c1-c5)(:$); infile datalines dsd dlm=','; datalines; 2,4,.,6,8,Two,Four,,Six,Eight ; /* Coalesce and Coalescec */ data coalesce; set have; array num {5} n1-n5; array char {5} c1-c5; a=coalesce(of num[*]); /* coalesce(of _numeric_); */ b=coalescec(of char[*]); /* coalescec(of _character_); */ run; /* Whichn and Whichc */ data which; set have; array num {5} n1-n5; array char {5} c1-c5; a=whichn(4, of num[*]); b=whichc('Four', of char[*]); run; /* Dim and Range */ data DimRange; set have; array num {5} n1-n5; array char {5} c1-c5; a=dim(char); b=range(of num[*]); run; /* Nmiss and Cmiss */ data NCMiss; set have; array num {5} n1-n5; array char {5} c1-c5; a=nmiss(of num[*]); b=cmiss(of char[*]); c=cmiss(of num[*], of char[*]); run;