Matrix Multiplication + Save Result by group

#1
Bonjour a tous,

I'm trying to achieve the following multiplication
VAR = W*S*W'

w: [n,1]
S: [n,n]
s: [n,1]

I have the following variables in Stata:
date W s

In my case, S is a square matrix [n,n] with 1 in the diagonal and a constant (per period) "s" in the diagonal.

The dimention "n" changes a each period "date" (by group). I want to save the result of this matrix multiplication for each "date" as a new variable "VAR".

I'm quite lost. Please help :( . Thanks a lot in advance