In reply to Dimitri.

Yes. What you are looking for is the UNIQUE-LOC technique. See "The UNIQUE-LOC trick" and the follow-up article "An efficient alternative to the UNIQUE-LOC technique". In your case, you can skip the UNIQUE step and just use the age groups of the mortality table as your categories, like this:

population_mortality= j(nrow(population_age), 1, 0); /* allocate */
do i = 1 to nrow(mortality_table);
idx = loc(population_age = mortality_table[i,1]);
if ncol(idx)>0 then
population_mortality[idx] = mortality_table[i,2];
end;
print population_age population_mortality;

The reason your code is taking a long time is because you are doing a scalar computation for each element of population_age. Notice that the technique I recomend does a vector computation for each of the age categories, and there are many fewer categories than people.