I have a variable with numerous (and varying) number of elements within it that is separated by a delimiter (;) and the following code below creates new variables for each observation based on the number of elements. Now as I am working through my analysis I am only interested in analyzing variables within the newly created ~30 that begin with 'abc' and was hoping someone would provide insight into the best way to go about this using SAS 9.4. The intended outcome is to identify key text after the initial 'abc' as well as to determine if key text is missing after the initial 'abc.' *Building an array without knowing the max number of variables; *proc sql stores a macro variable to determine the number of elements in the string to be applied - then the data step parses by the delimiter into the set amount determined by the proc sql step; proc sql noprint; select max(count(original,';'))+1 into :maxelements from have; Data want (drop=i); set have; array parsed_vars $ new1-new%eval(&maxelements); do i=1 to &maxelements; parsed_vars(i)=scan(original,i,";"); end; run;
... View more