s is not defined at the point where you call write. It is also a scalar, which doesn’t work with CSV.write. The following works fine. Hopefully you can adapt it to what you need.
function mar(x,y)
for i in 1:10
s=x*i+y
end
CSV.write("out.csv",(s = [s], x = [x], y = [x]))
end