Hello
I am new here.
I tried to find everywhere I know, but I cannot find how to reference a variable within a variable
here is my situation
ID N_DCODE N_TD_VOL N_TD_WT FQ_RICE FQ_BARLEY FQ_BIBIM
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 2305 0 15 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 2034 0 355 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0136 175 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1048 15 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 2034 0 300 1 7 1
A651183001 2002 0 110 1 7 1
A651183001 0243 0 220.3 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1505 0 76 1 7 1
A651183001 1609 0 3.1 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
this is part of the dataset.
and here is a FFQ(food frequency questionnaire) dataset merged with 24RC questionnaire dataset. There are two different surveys for the same kinds of food eaten. FFQ asks how often you eat foodA on a yearly basis, 24RC asks what exactly was eaten previous 24 hours.
I want to give a table for matching percentages of foodA to foodZ by FFQ & 24RC.
N_DCODE denotes which kind of food in 24RC survey. "2209" denotes strawberry
Is there an expression in stata to describe for example,
I will use the food match results to calculate match percentages and fill up the table.
thank you.
I am new here.
I tried to find everywhere I know, but I cannot find how to reference a variable within a variable
here is my situation
ID N_DCODE N_TD_VOL N_TD_WT FQ_RICE FQ_BARLEY FQ_BIBIM
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 2305 0 15 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 2034 0 355 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0136 175 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1048 15 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 2034 0 300 1 7 1
A651183001 2002 0 110 1 7 1
A651183001 0243 0 220.3 1 7 1
A651183001 1096 15 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1505 0 76 1 7 1
A651183001 1609 0 3.1 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1228 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 1113 25 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0368 37.5 0 1 7 1
A651183001 0563 390 0 1 7 1
A651183001 0368 37.5 0 1 7 1
this is part of the dataset.
and here is a FFQ(food frequency questionnaire) dataset merged with 24RC questionnaire dataset. There are two different surveys for the same kinds of food eaten. FFQ asks how often you eat foodA on a yearly basis, 24RC asks what exactly was eaten previous 24 hours.
I want to give a table for matching percentages of foodA to foodZ by FFQ & 24RC.
N_DCODE denotes which kind of food in 24RC survey. "2209" denotes strawberry
Is there an expression in stata to describe for example,
PHP Code:
by ID, sort: gen straw_match = 1 if (N_DCODE == "2209).N_TD_WT !=0 & FQ_STRAW !=0
replace straw_match = 0 if (ID.N_DCODE == "2209).N_TD_WT= 0 | FQ_STRAW =0
thank you.

Comment