How can I clear a line of a file?

Hello,

I want to clear or modify a line of a file. It is possible by

cat filename | sed '3d'

for example. But If I want "3" to be a variable?

I can't do sed '$var d'

Help me please

Thank you very much

sed "${var}d" filename