Hi all, I keep getting SO CLOSE but i can't get the final string to build. I'm trying to dynamically build a proc sql merge statement with table aliases of A and B. I have this: %let merge1=cat_order grp_order year; And i want to turn it into this: a.cat_order=b.cat_order and a.grp_order=b.grp_order and a.year=b.year. The ANDs can be constant, but the merge1 values will be different everytime (sometimes i might have 2 of them, sometimes 3, sometimes 1, etc), so i've been trying to build the statement by parsing the words with countw and scan and i can get it to build part way, but i can't get it to cycle and build completely. I can't put all of the code here because it's gone through about 10 different versions, so i don't even have some of the stuff i've tested so far, and what's left makes no sense because i got all turned around. Maybe i was THIS close and just missed one thing, but then i tore it all apart again. I don't know. I know in theory it's should be: count the words. (ie 3) <-- got this part to work. create new macro variables with the word "and", one for each count. (join1, join2, join3) <-- got this part to work. build a string for each cycle with the "a." aliases, etc onto them ( a.cat_order=b.cat_order and ) <-- got this part to work. Append the multiple strings together as one string <-- this is where i'm stuck. I built a dataset that has 3 fields with the content i want: string1=a.cat_order=b.cat_order and string2=a.grp_order=b.grp_order and string3=a.year=b.year But because the # can change, i can't get for the life of me get it to cycle through and retain the first part. I can't get %let str=str, string&i to work. I've tried %sysfunc(catx(,str), etc but i keep getting a %sysfuncf error?? I don't know. If anyone can help with the third part, that'd be great. Thanks M
... View more