An extra space exists after the word 'if'. This will lead the error message you posted.
I also didn't find the close parenthesis for 'while' statement. I have added it in the following code.
Normally i use Visual lisp(Autolisp) editor to check the missing bracket for simple skill programs .Does cadence has editor like vlisp editor that autodesk provides
Vi can check the missing bracket. Use '%' in command mode to find the matching bracket. Turning on the 'showmatch' switch will automatically show the matching bracket during input.