I am reposting this, as the previous one had some typos.
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 three lobes and each lobe is further divided into segments.
I need to create a variable called diffuse_nodule; that should fulfill the above definition criteria.
In one patient (patient_id), if any of the one lobes has all the segments present, this meets the definition of the diffuse nodule. Here below are the number of segment in each lung lobe.
- right_upper_lobe
- "Posterior"
- "anterior"
- "apical"
- right_middle_lobe
- "lateral"
- "medial"
- right_lower_lobe
- "anterior basal (r)"
- "lateral basal (r)"
- "medial basal (r)"
- "posterior basal (r)"
- "superior basal (r)"
- left_upper_lobe
- "anterior"
- "apicoposterior"
- left_middle_lobe
- "inferior lingular"
- "superior lingular"
- left_lower_lobe
- "anterior basal (l)"
- "lateral basal (l)"
- "medial basal (l)"
- "posterior basal (l)"
- "superior basal (l)"
once we create this new variable called diffuse_nodule, I need to separate it per-patient level. Please know that each patient in this dataset has multiple entries in rows.
Here is the dataex data.
clear
input byte(patient_id Nodule) str9 right_upper_lobe str7 right_middle_lobe str19 right_lower_lobe str14 left_upper_lobe str17 left_middle_lobe str19 left_lower_lobe
1 1 "apical" "medial" "superior basal (r)" "apicoposterior" "" ""
1 2 "anterior" "lateral" "anterior basal (r)" "" "" ""
1 3 "Posterior" "" "" "" "" ""
1 4 "" "" "" "" "" "superior basal (l)"
1 5 "" "" "" "" "" "anterior basal (l)"
1 6 "" "" "" "anterior" "superior lingular" ""
1 7 "" "" "" "" "" ""
1 8 "" "medial" "" "" "" ""
1 9 "" "" "" "" "" ""
2 1 "" "" "superior basal (r)" "" "" ""
2 2 "" "" "anterior basal (r)" "" "inferior lingular" "superior basal (l)"
2 3 "" "" "medial basal (r)" "" "" "anterior basal (l)"
2 4 "apical" "" "lateral basal (r)" "" "" "lateral basal (l)"
2 5 "" "medial" "posterior basal (r)" "anterior" "superior lingular" "medial basal (l)"
2 6 "" "" "" "" "" "posterior basal (l)"
3 1 "" "" "" "" "" ""
3 2 "" "" "" "" "" ""
3 3 "" "" "" "anterior" "" ""
4 1 "" "" "" "" "" ""
4 2 "" "" "" "" "superior lingular" ""
4 3 "" "" "" "" "inferior lingular" ""
4 4 "" "" "" "" "" ""
4 5 "" "" "" "anterior" "" "superior basal (l)"
4 6 "apical" "lateral" "" "" "" "anterior basal (l)"
5 1 "" "" "" "" "" "posterior basal (l)"
6 1 "" "" "superior basal (r)" "" "" "medial basal (l)"
6 2 "" "" "medial basal (r)" "" "" "lateral basal (l)"
6 3 "" "" "anterior basal (r)" "" "" ""
6 4 "" "medial" "" "" "superior lingular" ""
6 5 "" "" "" "apicoposterior" "" ""
6 6 "" "" "" "anterior" "" ""
6 7 "" "" "superior basal (r)" "" "" ""
6 8 "" "" "medial basal (r)" "" "" ""
6 9 "" "" "anterior basal (r)" "" "superior lingular" ""
6 10 "" "" "posterior basal (r)" "" "" ""
6 11 "" "" "lateral basal (r)" "" "" ""
6 12 "" "" "" "" "" ""
6 13 "" "" "" "" "" "superior basal (l)"
7 1 "" "" "" "" "" ""
7 2 "" "medial" "" "" "superior lingular" ""
7 3 "" "medial" "" "" "" ""
7 4 "" "" "" "apicoposterior" "" ""
7 5 "" "" "" "anterior" "" "anterior basal (l)"
8 1 "" "" "" "" "" ""
8 2 "" "lateral" "" "" "" ""
8 3 "" "lateral" "" "" "superior lingular" ""
8 4 "" "" "" "" "inferior lingular" "posterior basal (l)"
8 5 "" "" "" "" "" ""
8 6 "" "" "" "" "" ""
8 7 "apical" "medial" "" "" "" ""
9 1 "" "" "" "" "" ""
9 2 "" "" "" "" "" "posterior basal (l)"
9 3 "" "" "superior basal (r)" "" "" "posterior basal (l)"
9 4 "" "" "" "" "" "posterior basal (l)"
9 5 "" "" "" "" "" "posterior basal (l)"
10 1 "" "" "medial basal (r)" "anterior" "" ""
10 2 "" "" "anterior basal (r)" "" "" ""
10 3 "" "" "" "" "" ""
11 1 "" "" "" "" "" ""
11 2 "" "" "" "" "superior lingular" ""
12 1 "" "" "" "" "" ""
12 2 "apical" "medial" "" "anterior" "" "posterior basal (l)"
12 3 "" "lateral" "anterior basal (r)" "" "" ""
12 4 "" "" "anterior basal (r)" "" "inferior lingular" ""
12 5 "" "" "" "" "" ""
12 6 "" "" "" "" "" ""
12 7 "" "" "" "anterior" "" ""
12 8 "" "" "" "" "" ""
12 9 "" "" "" "" "" ""
12 10 "" "" "" "" "" ""
12 11 "" "" "" "apicoposterior" "" "medial basal (l)"
12 12 "" "" "" "" "" ""
12 13 "" "" "" "" "" ""
12 14 "" "" "medial basal (r)" "" "" ""
12 15 "" "" "medial basal (r)" "" "" "anterior basal (l)"
13 1 "" "" "medial basal (r)" "apicoposterior" "" ""
13 2 "" "" "medial basal (r)" "" "" ""
13 3 "apical" "" "" "" "" ""
13 4 "" "" "" "" "" ""
13 5 "" "" "posterior basal (r)" "apicoposterior" "" "anterior basal (l)"
13 6 "" "" "posterior basal (r)" "" "" ""
13 7 "" "" "posterior basal (r)" "" "" ""
13 8 "" "" "posterior basal (r)" "" "" ""
13 9 "" "medial" "" "" "" ""
13 10 "" "" "" "apicoposterior" "superior lingular" ""
13 11 "" "" "" "" "superior lingular" ""
13 12 "" "" "superior basal (r)" "" "" ""
14 1 "" "" "" "" "" ""
14 2 "" "" "" "" "" ""
14 3 "apical" "" "" "apicoposterior" "" ""
14 4 "" "" "" "" "" ""
14 5 "" "" "anterior basal (r)" "" "superior lingular" "anterior basal (l)"
14 6 "" "" "anterior basal (r)" "" "superior lingular" "lateral basal (l)"
14 7 "" "" "" "" "superior lingular" ""
14 8 "" "" "" "apicoposterior" "" ""
15 1 "" "" "" "" "" ""
15 2 "" "" "" "" "" ""
15 3 "" "" "" "" "" ""
15 4 "" "" "" "" "" ""
15 5 "" "" "" "apicoposterior" "" "medial basal (l)"
end
0 Response to creating new variable matching a definition
Post a Comment