Thank you for your response. Your solution works with the assumption you mentioned. Sorry I missed this important aspect, I just realized from looking at another dataset, that var1 per combination can be missing either var1=1 or var1=2. But the output needs to have per time group combination, var1=1 var1=2 and var1=3. This is a sample dataset (please notice the change in the last two observations): data have;
input time group var1 count percent;
datalines;
0 1 1 5 50
0 1 3 5 50
3 1 1 2 20
3 1 3 8 80
3 2 1 3 30
3 2 3 7 70
11 2 2 4 40
11 2 3 6 60;
run; The wanted output: time group var1 count percent 0 1 1 5 50 0 1 2 0 0 0 1 3 5 50 3 1 1 2 20 3 1 2 0 0 3 1 3 8 80 3 2 1 3 30 3 2 2 0 0 3 2 3 7 70 11 2 1 0 0 11 2 2 4 40 11 2 3 6 60 This should run only when either var1=1 or var1=2 are missing per combination.
... View more