The second error is probably from &complist, which you don't show. If it has a comma in it, then the %cnt_inv will interpret the parts after the comma as positional parameters. The macro needs a lot more work to handle things like &complist; there are examples in the macro manual.
To get at the first error, you need to add some of the macro debugging options (macrogen in particular would help).
Your order by clause should be a GROUP BY clause to go with the aggregate function COUNT.
I see single quotes around all macro variables in SQL Your previous post do not contain them. Variant with quotes is not correct. Please display &njcomplist. it is a good idea to run this code outside of the macro by assigning values (using %let) to all macro variables used.