if taking out steps might remove the problem, try doing the analysis without any of these extra steps that only provide a date at the start of a quarter. PROC MEANS will summarise by quarters, just by providing a suitable format for that class variable[pre] proc means nway data= original missing noprint;
var quantity ;
class country month product code ;
format month yyQ. ;
output out=work.test3( drop= _TYPE_ _FREQ_ ) sum= ;
run ;[/pre] I prefer the yyQ. format but you may prefer alternatives like YYQR and YYQx (with C,D,N,P or S for that x) or QTR without the year, or more exotically, construct your own format, with PROC FORMAT PICTURE...
but I see no reason why proc means would not include all obs it reads (unless your analysis variable QUANTITY is missing). Maybe you should keep _freq_ to check the number of obs in each class group add up to the grand total you expect.
If you must have the values of day, month, year on exactly the start of a quarter, perform that process on the summarised data. It will be quicker because there is less data. A simplistic assignment to transform the month to quarter start date[pre] q_start_date = intnx( 'qtr', month,0 ) ;[/pre]
good luck
PeterC