In the future, please always tell us what operating system and shell you're using when you start a thread in the Shell Programming and Scripting forum, and, when you get a syntax error, please show us the actual diagnostic message that you get when you try running your code.
In this case, I would guess that your problem is that standard implementations of awk do not include an elif clause in an if statement. If you change the elif in this case to else if :