The easiest way would be to write a function (since it's SKILL) and then use that:
Code:procedure(MYharm(netName harm)
let((signal harm1 harmN)
selectResult("FOUR0-tran.refer_fourier")
harm1=VAR("frequency")
harmN=harm1*harm
signal=v(netName)
value(dB20(signal / abs(value(signal harm1))) harmN)
))
Define this in your .cdsinit (or put it in a file that you load from the .cdsinit) and then all you need to use in the calculator is:
MYharm("/OUT" 3)
You could even create a custom calculator function out of this. There are lots of examples of that on sourcelink - for example, solution 11018920.
(Note, I didn't test the code above - it was just a transformation of your example).
Regards,
Andrew.