I don't see anything in your code that could cause the problem that you spoke of originally: "The problem I am having is that if for a country the same quantity is given twice (within the quarter) then PROC MEANS only take one of the two quantities."
Your code is not causing missing values to appear in the data. So it must be something in the data. Could you post some sample data?
By the way, there is no need for data set test2. It accomplishes little, and could be combined into data set test1.
data work.test1;
set work.test;
if Month in (1,2,3) then m=1;
else if Month in (4,5,6) then m=4;
else if Month in (7,8,9) then m=7;
else if Month in (10,11,12) then m=10;
date=mdy(m,01,year);
format date date7.;
drop m;
run;
... View more