You could use a loop.
Just use while(stat_points>0) and tell it to add points to a random variable.
To do this, you can have 2 global "temp" variables. For each loop, set temp1 to a random value, then under the loop, compare temp.
while
stat_points>0
always set temp1 to random(2)
always set temp2 to random(10)+1
if temp1=0, set STR to temp2
if temp1=1, set SPD to temp2
always subtract temp2 from stat_points
With this, stat_points could end up being negative and the sum of all stats could be greater than 100. If you want to make sure it equals exactly 100, you could limit the value 'temp2' gets by clamping it.
ex. set temp2 to clamp(random(10),1,'stat_points')
Temp1 is the variable it's giving points to. Temp2 is the how many points it gives that stat.
This will just keep allocating points to different stats until there are no more points left.
This will scale to any amount of stats, unlike the solution you came up with.
To make sure this only happens when the object spawns, I use an "initialized" flag on all objects. Make the default value of this = 0. Then test if initialized is 0 before doing the loop. When the loop is over, or anything else regarding initializing the object is done, set initialized to 1.
Temp variables are very useful because they can be used for anything. Lots of times you just need to temporarily use some variable to count things in a loop.
You can also point to different variables if you don't want to test temp1, say for example, if you have like 25 different stats, but you shouldn't need to worry about that.
This is how I'm making random weapons/armor pieces in my game.