I have a dataset as follows:
time return of stock a return of stock b eturn of stock c eturn of stock d eturn of stock e eturn of stock f eturn of stock g eturn of stock h
1 0.433 0.4343 -0.661 0.8766 0.48 0.71 0.72 0.33
n -0.5353 -0.424 0.146 0.11 0.97 0.23 -0.52 0.99
I've entered random data but that's not the main topic.

I'm looking at creating an extra variable in a column next to return of stock h that has the sum of squared differences of all stocks b-h from stock a for all time 1-n

so effectively for time = 1 specifically, i would like (return of stock b - return of stock a)^2 + (return of stock c - return of stock a)^2 +(return of stock d - return of stock a)^2 etc. until stock h

i'd like to repeat this process for time --> n for each row

how would I go about doing this?