This is my first post but I hope I have strictly followed the rules.

I have the following data

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str1 code long(weight price) float day
"A"   7 3801 15342
"B"   2 3801 15342
"B"   2 3801 15342
"B"   1 3801 15342
"A"  67 3801 15342
"A"  10 3801 15342
"B"  10 3801 15342
"A"   5 3801 15342
"B"   1 3801 15342
"B"   5 3801 15342
"A"   1 3801 15342
"B"   2 3799 15342
"B"   6 3800 15342
"B"   1 3797 15342
"A"   2 3797 15342
"B"  15 3798 15342
"B"  20 3800 15342
"A"   2 3797 15342
"A"   2 3799 15342
"A"  10 3798 15342
"A"  32 3797 15342
"A"   1 3800 15342
"B"   7 3797 15342
"B"  32 3797 15342
"B"  50 3795 15342
"A"  50 3795 15342
"A"   5 3798 15342
"A"   1 3797 15342
"A"   5 3797 15342
"A"  20 3800 15342
"B"   2 3797 15342
"A"   5 3800 15342
"A"   2 3793 15342
"B"   5 3793 15342
"A"   5 3790 15342
"A"   1 3793 15342
"B"   1 3793 15342
"B"  19 3794 15342
"B"  25 3794 15342
"A"  10 3794 15342
"B"   3 3793 15342
"B"   3 3794 15342
"B"   5 3794 15342
"A"   5 3791 15342
"B"   5 3791 15342
"A"   6 3797 15342
"A"   1 3797 15342
"A"  19 3794 15342
"A"   8 3794 15342
"B"  10 3796 15342
"B"   2 3793 15342
"B"   5 3794 15342
"A"  10 3796 15342
"B"   5 3790 15342
"B"   8 3794 15342
"A"   5 3793 15342
"B"   1 3797 15342
"B"   1 3793 15342
"A"   3 3794 15342
"B"   6 3797 15342
"A"   1 3793 15342
"A"  26 3794 15342
"A"   3 3793 15342
"B"   1 3706 15372
"A"   1 3705 15372
"A"  24 3706 15372
"A"   1 3706 15372
"A"  25 3706 15372
"B"   5 3706 15372
"A"  20 3706 15372
"B"   1 3706 15372
"B"  38 3706 15372
"A"   1 3705 15372
"B"  24 3706 15372
"B"   5 3706 15372
"A"  25 3706 15372
"B"  20 3706 15372
"A"   5 3706 15372
"B"   1 3705 15372
"A"  18 3706 15372
"B"   5 3705 15372
"A"  25 3706 15372
"A" 100 3706 15372
"B"   1 3706 15372
"A"   5 3705 15372
"A"   3 3705 15372
"B"   1 3706 15372
"A"  44 3706 15372
"A"   5 3706 15372
"A"  25 3706 15372
"B"   1 3705 15372
"B"   4 3705 15372
"A"   5 3705 15372
"A"   5 3705 15372
"A"  50 3706 15372
"A"   1 3706 15372
"B" 321 3706 15372
"B"   5 3705 15372
"A"  40 3706 15372
"B"   1 3705 15372
end
I am using the following simple code:

* computing daily average
bys day: egen avask = mean(cond(code == "A",price,.))


* computing weighted daily average
bys day: egen wavask = wtmean(cond(code == "A",price,.)), weight(weight)


Stata does not complain when attempting the computation of the (unweighted) average but it issues an error when it arrives at the weighted one. The error is

A not found

I would appreciate any feedback on this.