Yes, this is in fact possible. I tried to do this a while back and eventually figured it out.
now, when you wrote getdammage a_unit, ofp thought the whole variable was a_unit, and didn't think unit was a variable name. So, waht we need ofp to do is compile the name via a string, and then "execute" the string.
So, off the top of my head, what I'd do is something like:
_unit=7 //Defines initial number
_string = "a" + format ["%1",_unit] //Creates a string and turns the variable "_unit" into a string so it can be concatenated
_variable=(GetDammage call _string) //gets the damage of the string by "executing" it with the call command. Call turns scripts into executable code.
hint format ["Damage to %1 = %2\n%3",_unit,_variable,_string] //gives you a sample output so you can see if all the variables are spiffy.
exit
This code worked fine on a unit I named "a7" in the editor.