Hi, thanks again for all of your help. As follow up to this string, I'm attempting to define another array from the first array, words_parsed. The second array, search_fields, I'm hoping to use the full range of words being parsed, which is based upon &maxwords macro variable. However, in this new array I want to add an additional field, owner_city, to be a part of the elements. So I created a separate macro, num_elements, which is just &maxwords + 1. However, I'm encountering below log error. I'm not sure how to reference the &maxwords macro when defining the elements in the array. The elements I want to include in the search_fields array are: owner_city words_parsed1-words_parsed(# based upon &maxwords. macro) . Here's the code as well.
Any assistance would be much appreciated.
Andy
data _null_; set stacked (keep= owner_city owner_type2); where owner_type2 = 'OUT_CNTRY';
retain maxwords;
num_words_own_city = countw(owner_city, ' '); maxwords=max(maxwords,num_words_own_city); num_elements = maxwords + 1;
call symput('maxwords',maxwords); call symput('num_elements',num_elements); run;
%put max word count: &maxwords number of search elements: &num_elements ;
*-------------------------------------------------------------------------------------------------------*; * Based upon max word count, parse & extract words to new columns for comparison against intl file *; *-------------------------------------------------------------------------------------------------------*;
data intl; set stacked; length owner_country $2.; where owner_type2 = 'OUT_CNTRY';
/*create an array to represent the words extracted from the owner_city field - count of words is variable*/
array words_parsed {&maxwords.} $60 ;
/*iterate through owner city field parsing out word by word untill iterations > the count of words*/
do i=1 to countw(owner_city, ' '); words_parsed{i} = strip(upcase(scan(owner_city, i,' '))); end;
array search_fields {&num_elements.} $60 /*owner_city words_parsed1 words_parsed2 words_parsed3*/ owner_city words_parsed1-words_parsed{&maxwords.};
run;
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
39 array search_fields {&num_elements.} $60 /*owner_city words_parsed1 words_parsed2 words_parsed3*/ owner_city 39 ! words_parsed1-words_parsed{&maxwords.}; _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, (, ;, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_.
ERROR 76-322: Syntax error, statement will be ignored.
... View more