Dear Stata Users,

as mentioned in the thread title I got a question regarding parallel looping in Stata. I have cross tabulated two variables, namely variable 1 “job_code” and variable 2 “sector_code”. What I receive is a table that looks similar to this one:
job_code sector_code
1 2 3
111 101 57 18
112 19 18 56
211 4 11 21
215 17 34 86
What I want to do now is to generate a variable with a new value for each cell of the cross table. I could compute such a variable manually by using the following code lines.

gen sectorjobcell=.
replace sectorjobcell=1 if if job_code==111 & sector_code==1
replace sectorjobcell=2 if if job_code==112 & sector_code==1
replace sectorjobcell=3 if if job_code==211 & sector_code==1


But since there are somewhat over a few hundred sector-job-cells I need to automate the procedure. I thought about using foreach loops in order to solve the problem but couldn’t figure out how to run them parallelly. What I need is a way to implement a loop that changes the values of "job_code" & "sector_code" at the same.

Any hint or comment would be much appeciated.

Thanks in advance!
Tom