M21man has the right syntax. It should fix the error you're getting. Also, you may want to consider not deleting all units as others have said. If you have a large enough scale of a mission to require deleting units in the first place, you should be using createunit command to fill in your battle(s). Adding the eventhandler to the created units and deleting them works fine, and the bodies from the original groups you placed in the editor will still be there to keep appearances proper,and scavenge items from. It's a good compromise I find works well. Here's the eventhandler I use for deleting units:
;---------------------------------------------
_unit = _this select 0
~15 + (random 30)
_unit removealleventhandlers "killed"
deletevehicle _unit
;---------------------------------------------
Just for kicks, here's my latest createunit script if you want it.
;simple create script by -CrashnBurn-.
;randomizes unit type, skill and rank.
;-------------------------------------
#TOP
_pos = _this select 0
_grp = _this select 1
_units = units _grp
;-----------------------------------------------------------------------------
_typeArray = ["SoldierEB","SoldierEG","SoldierELAW","SoldierEMedic","SoldierEB","SoldierEMG","SoldierEB","SoldierEG","OfficerE"]
_type = _typeArray select (random 8)
;---------------------------------------------------
_skillArray = [1.0, 0.9, 0.7, 1.0, 0.8, 0.9]
_skill = _skillArray select (random 5)
;---------------------------------------------------
_rankArray = ["SERGEANT","CORPORAL","PRIVATE"]
_rank = _rankArray select (random 2)
;-------------------------------------------------------------------------------
_type createunit [_pos,_grp,"this setunitpos {UP}; this allowfleeing 0; this addeventhandler [{killed},{_this exec {rid.sqs}}]",_skill,_rank]
;-----------------------------------------------------------------------------
~1 + (random 3)
_count = ({alive _x} count _units)
? (_count < 12): goto "TOP"
;Hint format ["%1 units were created", _count]
exit