Creating table of the mean and sd of one variable over other variables with different groups

almost there.
can you provide sufficient example data, i.e. total2017 so as to produce some output against your code ?

FAQ: How to do a minimal reproducible example ( reprex ) for beginners