You're on the right track; the main problem is the parentheses around the $rand(1,3) -- It should just be:
var %randnumber $rand(1,3)
otherwise the ( ) will be part of the variable, (e.g. ( 1) rather than 1)