Hello. Please consider the example of my data below:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte likes int(date date1) str4 colour byte SUMIFSred
1 18105 18001 "Red"  0
0 18159 18002 "Blue" 0
1 18161 18003 "Red"  0
1 18161 18004 "Blue" 0
2 18222 18005 "Blue" 0
1 18225 18006 "Red"  0
2 18226 18160 "Red"  0
1 18252 18161 "Blue" 1
3 18253 18009 "Red"  0
1 18261 18010 "Blue" 0
1 18261 18011 "Red"  0
1 18276 18012 "Blue" 0
1 18276 18013 "Red"  0
0 18276 18105 "Red"  1
end
format %tddd-Mon-YY date
format %tddd-Mon-YY date1
I would like to know a way to get the last variable, SUMIFSred. The way it is derived is by taking the sum of the variable, likes, if the variable, Date1, is found in the variable, Date, and "Red" is found in the variable, colour.

I have tried with the following code but it does not quite work out:

save tmpfile1, replace
collapse (sum) total_likes_ifs_red = likes if colour == "Red", by(date)
ren date date1
merge 1:m date1 using tmpfile1
drop if _merge==1
drop _merge

Please help. Thank you.