Hello,

Here I have a request that is a little complicated. I will try to make is simple and logical.
I need to count the diffuse nodule (defined as below) in each patient in the data (example data is below).

Diffuse Nodule Definition: all the segments of at least one lung LOBE should have nodules in one patient.
Each patient has 2 lungs.
Each lung is divided into different lobes and segments as in the table.

I need to create a variable called nodule; that should fulfill the above definition criteria.
Right lung Left Lung
Right Upper Lobe Left Upper Lobe
Apical Apicoposterior
Anterior Posterior
Posterior
Right Middle Lobe Left middle lobe of Lingula
Medial Superior Lingula
Lateral Inferior Lingula
Right Lower Lobe Left Lower Lobe
Superior basal right Superior basal Left
Medical basal right Medical basal Left
Anterior basal right Anterior basal Left
Posterior basal right Posterior basal Left
Lateral basal right Lateral basal Left
For example: if in one patient (patient_id), if all the five segments (SBL, MBL, ABL, PBL, LBL) are present, this meets the definition of the diffuse nodule. Similarly for the right middle lobe, if both segments (medial and lateral) are present, that makes it diffuse nodule.



clear
input byte(patient_id Nodule) str6(RUL RML) str3 RLL str2(LUL LMD) str3 LLL
1 1 "Apical" "M" "SBR" "AP" "" ""
1 2 "A" "L" "ABR" "" "" ""
1 3 "P" "" "" "" "" ""
1 4 "" "" "" "" "" "SBL"
1 5 "" "" "" "" "" "ABL"
1 6 "" "" "" "P" "SL" ""
1 7 "" "" "" "" "" ""
1 8 "" "M" "" "" "" ""
1 9 "" "" "" "" "" ""
2 1 "" "" "SBR" "" "" ""
2 2 "" "" "ABR" "" "IL" "SBL"
2 3 "" "" "MBR" "" "" "ABL"
2 4 "Apical" "" "LBR" "" "" "LBL"
2 5 "" "M" "PBS" "P" "SL" "MBL"
2 6 "" "" "" "" "" "PBL"
3 1 "" "" "" "" "" ""
3 2 "" "" "" "" "" ""
3 3 "" "" "" "P" "" ""
4 1 "" "" "" "" "" ""
4 2 "" "" "" "" "SL" ""
4 3 "" "" "" "" "IL" ""
4 4 "" "" "" "" "" ""
4 5 "" "" "" "P" "" "SBL"
4 6 "Apical" "L" "" "" "" "ABL"
5 1 "" "" "" "" "" "PBL"
6 1 "" "" "SBR" "" "" "MBL"
6 2 "" "" "MBS" "" "" "LBL"
6 3 "" "" "ABR" "" "" ""
6 4 "" "M" "" "" "SL" ""
6 5 "" "" "" "AP" "" ""
6 6 "" "" "" "P" "" ""
6 7 "" "" "SBR" "" "" ""
6 8 "" "" "MBS" "" "" ""
6 9 "" "" "ABR" "" "SL" ""
6 10 "" "" "PBR" "" "" ""
6 11 "" "" "LBR" "" "" ""
6 12 "" "" "" "" "" ""
6 13 "" "" "" "" "" "SBL"
7 1 "" "" "" "" "" ""
7 2 "" "M" "" "" "SL" ""
7 3 "" "M" "" "" "" ""
7 4 "" "" "" "AP" "" ""
7 5 "" "" "" "P" "" "ABL"
8 1 "" "" "" "" "" ""
8 2 "" "L" "" "" "" ""
8 3 "" "L" "" "" "SL" ""
8 4 "" "" "" "" "IL" "PBL"
8 5 "" "" "" "" "" ""
8 6 "" "" "" "" "" ""
8 7 "Apical" "M" "" "" "" ""
9 1 "" "" "" "" "" ""
9 2 "" "" "" "" "" "PBL"
9 3 "" "" "SBR" "" "" "PBL"
9 4 "" "" "" "" "" "PBL"
9 5 "" "" "" "" "" "PBL"
10 1 "" "" "MBR" "P" "" ""
10 2 "" "" "ABR" "" "" ""
10 3 "" "" "" "" "" ""
11 1 "" "" "" "" "" ""
11 2 "" "" "" "" "SL" ""
12 1 "" "" "" "" "" ""
12 2 "Apical" "medlal" "" "P" "" "PBL"
12 3 "" "L" "ABR" "" "" ""
12 4 "" "" "ABR" "" "IL" ""
12 5 "" "" "" "" "" ""
12 6 "" "" "" "" "" ""
12 7 "" "" "" "P" "" ""
12 8 "" "" "" "" "" ""
12 9 "" "" "" "" "" ""
12 10 "" "" "" "" "" ""
12 11 "" "" "" "AP" "" "MBL"
12 12 "" "" "" "" "" ""
12 13 "" "" "" "" "" ""
12 14 "" "" "MBR" "" "" ""
12 15 "" "" "MBR" "" "" "ABL"
13 1 "" "" "MBR" "AP" "" ""
13 2 "" "" "MBR" "" "" ""
13 3 "Apical" "" "" "" "" ""
13 4 "" "" "" "" "" ""
13 5 "" "" "PBR" "AP" "" "ABL"
13 6 "" "" "PBR" "" "" ""
13 7 "" "" "PBR" "" "" ""
13 8 "" "" "PBR" "" "" ""
13 9 "" "M" "" "" "" ""
13 10 "" "" "" "AP" "SL" ""
13 11 "" "" "" "" "SL" ""
13 12 "" "" "SBR" "" "" ""
14 1 "" "" "" "" "" ""
14 2 "" "" "" "" "" ""
14 3 "Apical" "" "" "AP" "" ""
14 4 "" "" "" "" "" ""
14 5 "" "" "ABR" "" "SL" "ABL"
14 6 "" "" "ABR" "" "SL" "LBL"
14 7 "" "" "" "" "SL" ""
14 8 "" "" "" "AP" "" ""
15 1 "" "" "" "" "" ""
15 2 "" "" "" "" "" ""
15 3 "" "" "" "" "" ""
15 4 "" "" "" "" "" ""
15 5 "" "" "" "AP" "" "MBL"
end