Before starting this exercise, you should have the “Digital.dta” file. (Download link is given below)
Click here to download – “Digital.dta”
Importing the “Digital.dta” file.
set maxvar 10000
use "/Users/pankajchowdhury/Downloads/Digital.dta"
I have the file located at "/Users/pankajchowdhury/Downloads/Digital.dta"
. Feel free to modify the file path according to your needs.
Observations: | 724115 | |||
Variables: | 31 | |||
Variable name | Storage type | Display format | Value label | Variable label |
v005 | long | %12.0g | v005 | women's individual sample weight (6 decimals) |
v013 | byte | %8.0g | V013 | age in 5-year groups |
v024 | byte | %8.0g | V024 | state |
v025 | byte | %8.0g | V025 | type of place of residence |
v130 | byte | %8.0g | V130 | religion |
v133 | byte | %8.0g | V133 | education in single years |
v151 | byte | %8.0g | V151 | sex of household head |
v157 | byte | %8.0g | V157 | frequency of reading newspaper or magazine |
v158 | byte | %8.0g | V158 | frequency of listening to radio |
v159 | byte | %8.0g | V159 | frequency of watching television |
v169a | byte | %8.0g | V169A | owns a mobile telephone |
v190 | byte | %8.0g | V190 | wealth index combined |
v217 | byte | %8.0g | V217 | knowledge of ovulatory cycle |
v504 | byte | %8.0g | V504 | currently residing with husband/partner |
v702 | byte | %8.0g | V702 | husband/partner's highest year of education (at level in v701) |
v704 | byte | %8.0g | V704 | husband/partner's occupation |
v715 | byte | %8.0g | V715 | husband/partner's total number of years of education |
v730 | byte | %8.0g | V730 | husband/partner's age |
v743f | byte | %8.0g | V743F | person who usually decides what to do with money husband earns |
v746 | byte | %8.0g | V746 | respondent earns more than husband/partner |
d005 | long | %12.0g | d005 | weight for domestic violence (6 decimals) |
d102 | byte | %8.0g | d012 | number of control issues answered 'yes' (d101x = 1) |
sweight | long | %12.0g | sweight | sample weight (6 decimals) (state level) |
s116 | byte | %8.0g | S116 | belong to a scheduled caste, a scheduled tribe, other backward class |
s303 | int | %8.0g | S303 | time period not living with husband |
s311 | byte | %8.0g | S311 | type of relationship to current husband,prior to marriage |
s931 | byte | %8.0g | S931 | do you have a bank or savings account that you yourself use |
s932 | byte | %8.0g | S932 | do you have any mobile phone that you yourself use |
s933 | byte | %8.0g | S933 | do you use your mobile phone for any financial transaction ? |
s934 | byte | %8.0g | S934 | have you ever used the internet? |
s1004p | byte | %8.0g | S1004P | source of information about aids: internet |
Code 1.1:
codebook v730
ta v730
Result : codebook v730
– This command will check the variable type, variable label, Range, Unique values, value label and frequency distribution of a particular variable “v730”.
codebook | v730 | ||
v730 : | husband/partner's age | ||
Type: | Numeric (byte) | ||
Label: | V730, but 74 nonmissing values are not labeled | ||
Range: | [15,95] | Units: | 1 |
Unique values: | 74 | Missing : | 647,033/724,115 |
Code 1.2:
ta v730
Result :
husband/partner's age | Freq. | Percent | Cum. |
---|---|---|---|
15 | 48 | 0.06 | 0.06 |
16 | 11 | 0.01 | 0.08 |
17 | 27 | 0.04 | 0.11 |
18 | 102 | 0.13 | 0.24 |
19 | 151 | 0.2 | 0.44 |
20 | 394 | 0.51 | 0.95 |
21 | 526 | 0.68 | 1.63 |
22 | 846 | 1.1 | 2.73 |
23 | 925 | 1.2 | 3.93 |
24 | 1,321 | 1.71 | 5.64 |
25 | 2,236 | 2.9 | 8.55 |
26 | 1,828 | 2.37 | 10.92 |
27 | 2,076 | 2.69 | 13.61 |
28 | 2,600 | 3.37 | 16.98 |
29 | 1,937 | 2.51 | 19.5 |
30 | 4,130 | 5.36 | 24.85 |
31 | 1,736 | 2.25 | 27.11 |
32 | 3,203 | 4.16 | 31.26 |
33 | 1,983 | 2.57 | 33.83 |
34 | 2,309 | 3 | 36.83 |
35 | 4,704 | 6.1 | 42.93 |
36 | 2,343 | 3.04 | 45.97 |
37 | 2,032 | 2.64 | 48.61 |
38 | 2,859 | 3.71 | 52.32 |
39 | 1,959 | 2.54 | 54.86 |
40 | 4,437 | 5.76 | 60.61 |
41 | 1,525 | 1.98 | 62.59 |
42 | 2,566 | 3.33 | 65.92 |
43 | 1,608 | 2.09 | 68.01 |
44 | 1,719 | 2.23 | 70.24 |
45 | 4,199 | 5.45 | 75.69 |
46 | 1,780 | 2.31 | 77.99 |
47 | 1,752 | 2.27 | 80.27 |
48 | 2,390 | 3.1 | 83.37 |
49 | 1,671 | 2.17 | 85.54 |
50 | 2,619 | 3.4 | 88.93 |
51 | 1,316 | 1.71 | 90.64 |
52 | 1,673 | 2.17 | 92.81 |
53 | 1,030 | 1.34 | 94.15 |
54 | 1,014 | 1.32 | 95.46 |
55 | 812 | 1.05 | 96.52 |
56 | 595 | 0.77 | 97.29 |
57 | 448 | 0.58 | 97.87 |
58 | 454 | 0.59 | 98.46 |
59 | 266 | 0.35 | 98.8 |
60 | 367 | 0.48 | 99.28 |
61 | 90 | 0.12 | 99.4 |
62 | 106 | 0.14 | 99.53 |
63 | 62 | 0.08 | 99.61 |
64 | 40 | 0.05 | 99.67 |
65 | 78 | 0.1 | 99.77 |
66 | 23 | 0.03 | 99.8 |
67 | 19 | 0.02 | 99.82 |
68 | 17 | 0.02 | 99.84 |
69 | 13 | 0.02 | 99.86 |
70 | 29 | 0.04 | 99.9 |
71 | 4 | 0.01 | 99.9 |
72 | 3 | 0 | 99.91 |
73 | 4 | 0.01 | 99.91 |
74 | 5 | 0.01 | 99.92 |
75 | 2 | 0 | 99.92 |
76 | 1 | 0 | 99.92 |
77 | 1 | 0 | 99.92 |
78 | 1 | 0 | 99.93 |
79 | 1 | 0 | 99.93 |
80 | 5 | 0.01 | 99.93 |
82 | 3 | 0 | 99.94 |
83 | 1 | 0 | 99.94 |
84 | 1 | 0 | 99.94 |
85 | 1 | 0 | 99.94 |
87 | 1 | 0 | 99.94 |
88 | 1 | 0 | 99.94 |
90 | 1 | 0 | 99.95 |
95 | 42 | 0.05 | 100 |
Total | 77,082 | 100 | |
Explanation : ta v730
– this command will provide a frequency table comprising cumulative frequency and percentage distribution for variable v730.
Code 2:
gen five_year = 5
ta five_year
Explanation : gen five_year = 5
this command will create a variable that assigns the value of “5” to each observation.
Code 3:
gen int age_plus_five = v730 + five_year
ta age_plus_five
Explanation : gen int age_plus_five = v730 + five_year
– create a fresh variable ( variable type: int) by incrementing each value in the variable v730 by 5.
Result :
age_plus_five (v730+ Five year) | Freq. | Percent | Cum. |
---|---|---|---|
20 | 48 | 0.06 | 0.06 |
21 | 11 | 0.01 | 0.08 |
22 | 27 | 0.04 | 0.11 |
23 | 102 | 0.13 | 0.24 |
24 | 151 | 0.2 | 0.44 |
25 | 394 | 0.51 | 0.95 |
26 | 526 | 0.68 | 1.63 |
27 | 846 | 1.1 | 2.73 |
28 | 925 | 1.2 | 3.93 |
29 | 1,321 | 1.71 | 5.64 |
30 | 2,236 | 2.9 | 8.55 |
31 | 1,828 | 2.37 | 10.92 |
32 | 2,076 | 2.69 | 13.61 |
33 | 2,600 | 3.37 | 16.98 |
34 | 1,937 | 2.51 | 19.5 |
35 | 4,130 | 5.36 | 24.85 |
36 | 1,736 | 2.25 | 27.11 |
37 | 3,203 | 4.16 | 31.26 |
38 | 1,983 | 2.57 | 33.83 |
39 | 2,309 | 3 | 36.83 |
40 | 4,704 | 6.1 | 42.93 |
41 | 2,343 | 3.04 | 45.97 |
42 | 2,032 | 2.64 | 48.61 |
43 | 2,859 | 3.71 | 52.32 |
44 | 1,959 | 2.54 | 54.86 |
45 | 4,437 | 5.76 | 60.61 |
46 | 1,525 | 1.98 | 62.59 |
47 | 2,566 | 3.33 | 65.92 |
48 | 1,608 | 2.09 | 68.01 |
49 | 1,719 | 2.23 | 70.24 |
50 | 4,199 | 5.45 | 75.69 |
51 | 1,780 | 2.31 | 77.99 |
52 | 1,752 | 2.27 | 80.27 |
53 | 2,390 | 3.1 | 83.37 |
54 | 1,671 | 2.17 | 85.54 |
55 | 2,619 | 3.4 | 88.93 |
56 | 1,316 | 1.71 | 90.64 |
57 | 1,673 | 2.17 | 92.81 |
58 | 1,030 | 1.34 | 94.15 |
59 | 1,014 | 1.32 | 95.46 |
60 | 812 | 1.05 | 96.52 |
61 | 595 | 0.77 | 97.29 |
62 | 448 | 0.58 | 97.87 |
63 | 454 | 0.59 | 98.46 |
64 | 266 | 0.35 | 98.8 |
65 | 367 | 0.48 | 99.28 |
66 | 90 | 0.12 | 99.4 |
67 | 106 | 0.14 | 99.53 |
68 | 62 | 0.08 | 99.61 |
69 | 40 | 0.05 | 99.67 |
70 | 78 | 0.1 | 99.77 |
71 | 23 | 0.03 | 99.8 |
72 | 19 | 0.02 | 99.82 |
73 | 17 | 0.02 | 99.84 |
74 | 13 | 0.02 | 99.86 |
75 | 29 | 0.04 | 99.9 |
76 | 4 | 0.01 | 99.9 |
77 | 3 | 0 | 99.91 |
78 | 4 | 0.01 | 99.91 |
79 | 5 | 0.01 | 99.92 |
80 | 2 | 0 | 99.92 |
81 | 1 | 0 | 99.92 |
82 | 1 | 0 | 99.92 |
83 | 1 | 0 | 99.93 |
84 | 1 | 0 | 99.93 |
85 | 5 | 0.01 | 99.93 |
87 | 3 | 0 | 99.94 |
88 | 1 | 0 | 99.94 |
89 | 1 | 0 | 99.94 |
90 | 1 | 0 | 99.94 |
92 | 1 | 0 | 99.94 |
93 | 1 | 0 | 99.94 |
95 | 1 | 0 | 99.95 |
100 | 42 | 0.05 | 100 |
Total | 77,082 | 100 |
Code 4:
gen int age_plus_five2 = v730 + five_year if v730 > 25 ta age_plus_five2
Explanation : gen int age_plus_five2 = v730 + five_year if v730 > 25
– When the age variable (v730) exceeds 30 years, executing this command will produce a new variable by incrementing each observation in v730 by five.
Results :
age_plus_five2 | Freq. | Percent | Cum. |
---|---|---|---|
31 | 1,828 | 2.59 | 2.59 |
32 | 2,076 | 2.94 | 5.54 |
33 | 2,600 | 3.69 | 9.23 |
34 | 1,937 | 2.75 | 11.97 |
35 | 4,130 | 5.86 | 17.83 |
36 | 1,736 | 2.46 | 20.3 |
37 | 3,203 | 4.54 | 24.84 |
38 | 1,983 | 2.81 | 27.65 |
39 | 2,309 | 3.28 | 30.93 |
40 | 4,704 | 6.67 | 37.6 |
41 | 2,343 | 3.32 | 40.92 |
42 | 2,032 | 2.88 | 43.81 |
43 | 2,859 | 4.06 | 47.86 |
44 | 1,959 | 2.78 | 50.64 |
45 | 4,437 | 6.29 | 56.93 |
46 | 1,525 | 2.16 | 59.1 |
47 | 2,566 | 3.64 | 62.74 |
48 | 1,608 | 2.28 | 65.02 |
49 | 1,719 | 2.44 | 67.46 |
50 | 4,199 | 5.96 | 73.41 |
51 | 1,780 | 2.53 | 75.94 |
52 | 1,752 | 2.49 | 78.42 |
53 | 2,390 | 3.39 | 81.81 |
54 | 1,671 | 2.37 | 84.18 |
55 | 2,619 | 3.72 | 87.9 |
56 | 1,316 | 1.87 | 89.77 |
57 | 1,673 | 2.37 | 92.14 |
58 | 1,030 | 1.46 | 93.6 |
59 | 1,014 | 1.44 | 95.04 |
60 | 812 | 1.15 | 96.19 |
61 | 595 | 0.84 | 97.04 |
62 | 448 | 0.64 | 97.67 |
63 | 454 | 0.64 | 98.31 |
64 | 266 | 0.38 | 98.69 |
65 | 367 | 0.52 | 99.21 |
66 | 90 | 0.13 | 99.34 |
67 | 106 | 0.15 | 99.49 |
68 | 62 | 0.09 | 99.58 |
69 | 40 | 0.06 | 99.64 |
70 | 78 | 0.11 | 99.75 |
71 | 23 | 0.03 | 99.78 |
72 | 19 | 0.03 | 99.81 |
73 | 17 | 0.02 | 99.83 |
74 | 13 | 0.02 | 99.85 |
75 | 29 | 0.04 | 99.89 |
76 | 4 | 0.01 | 99.9 |
77 | 3 | 0 | 99.9 |
78 | 4 | 0.01 | 99.9 |
79 | 5 | 0.01 | 99.91 |
80 | 2 | 0 | 99.91 |
81 | 1 | 0 | 99.92 |
82 | 1 | 0 | 99.92 |
83 | 1 | 0 | 99.92 |
84 | 1 | 0 | 99.92 |
85 | 5 | 0.01 | 99.93 |
87 | 3 | 0 | 99.93 |
88 | 1 | 0 | 99.93 |
89 | 1 | 0 | 99.93 |
90 | 1 | 0 | 99.94 |
92 | 1 | 0 | 99.94 |
93 | 1 | 0 | 99.94 |
95 | 1 | 0 | 99.94 |
100 | 42 | 0.06 | 100 |
Total | 70,495 | 100 |
Code 5:
gen age2 = v730^2
ta age2
Explanation : gen age2 = v730^2
– By squaring the variable values, this command will create a new variable.
Results :
age2 | Freq. Perc | ent | Cum. |
---|---|---|---|
225 | 48 | 0.06 | 0.06 |
256 | 11 | 0.01 | 0.08 |
289 | 27 | 0.04 | 0.11 |
324 | 102 | 0.13 | 0.24 |
361 | 151 | 0.2 | 0.44 |
400 | 394 | 0.51 | 0.95 |
441 | 526 | 0.68 | 1.63 |
484 | 846 | 1.1 | 2.73 |
529 | 925 | 1.2 | 3.93 |
576 | 1,321 | 1.71 | 5.64 |
625 | 2,236 | 2.9 | 8.55 |
676 | 1,828 | 2.37 | 10.92 |
729 | 2,076 | 2.69 | 13.61 |
784 | 2,600 | 3.37 | 16.98 |
841 | 1,937 | 2.51 | 19.5 |
900 | 4,130 | 5.36 | 24.85 |
961 | 1,736 | 2.25 | 27.11 |
1024 | 3,203 | 4.16 | 31.26 |
1089 | 1,983 | 2.57 | 33.83 |
1156 | 2,309 | 3 | 36.83 |
1225 | 4,704 | 6.1 | 42.93 |
1296 | 2,343 | 3.04 | 45.97 |
1369 | 2,032 | 2.64 | 48.61 |
1444 | 2,859 | 3.71 | 52.32 |
1521 | 1,959 | 2.54 | 54.86 |
1600 | 4,437 | 5.76 | 60.61 |
1681 | 1,525 | 1.98 | 62.59 |
1764 | 2,566 | 3.33 | 65.92 |
1849 | 1,608 | 2.09 | 68.01 |
1936 | 1,719 | 2.23 | 70.24 |
2025 | 4,199 | 5.45 | 75.69 |
2116 | 1,780 | 2.31 | 77.99 |
2209 | 1,752 | 2.27 | 80.27 |
2304 | 2,390 | 3.1 | 83.37 |
2401 | 1,671 | 2.17 | 85.54 |
2500 | 2,619 | 3.4 | 88.93 |
2601 | 1,316 | 1.71 | 90.64 |
2704 | 1,673 | 2.17 | 92.81 |
2809 | 1,030 | 1.34 | 94.15 |
2916 | 1,014 | 1.32 | 95.46 |
3025 | 812 | 1.05 | 96.52 |
3136 | 595 | 0.77 | 97.29 |
3249 | 448 | 0.58 | 97.87 |
3364 | 454 | 0.59 | 98.46 |
3481 | 266 | 0.35 | 98.8 |
3600 | 367 | 0.48 | 99.28 |
3721 | 90 | 0.12 | 99.4 |
3844 | 106 | 0.14 | 99.53 |
3969 | 62 | 0.08 | 99.61 |
4096 | 40 | 0.05 | 99.67 |
4225 | 78 | 0.1 | 99.77 |
4356 | 23 | 0.03 | 99.8 |
4489 | 19 | 0.02 | 99.82 |
4624 | 17 | 0.02 | 99.84 |
4761 | 13 | 0.02 | 99.86 |
4900 | 29 | 0.04 | 99.9 |
5041 | 4 | 0.01 | 99.9 |
5184 | 3 | 0 | 99.91 |
5329 | 4 | 0.01 | 99.91 |
5476 | 5 | 0.01 | 99.92 |
5625 | 2 | 0 | 99.92 |
5776 | 1 | 0 | 99.92 |
5929 | 1 | 0 | 99.92 |
6084 | 1 | 0 | 99.93 |
6241 | 1 | 0 | 99.93 |
6400 | 5 | 0.01 | 99.93 |
6724 | 3 | 0 | 99.94 |
6889 | 1 | 0 | 99.94 |
7056 | 1 | 0 | 99.94 |
7225 | 1 | 0 | 99.94 |
7569 | 1 | 0 | 99.94 |
7744 | 1 | 0 | 99.94 |
8100 | 1 | 0 | 99.95 |
9025 | 42 | 0.05 | 100 |
Total | 77,082 | 100 |
Code 6:
gen age = sqrt(age2) ta age
Explanation :
gen age = sqrt(age2)
– This command will create a new variable by substituting the variable values with their square root.
Results:
age | Freq. | Percent | Cum. |
---|---|---|---|
15 | 48 | 0.06 | 0.06 |
16 | 11 | 0.01 | 0.08 |
17 | 27 | 0.04 | 0.11 |
18 | 102 | 0.13 | 0.24 |
19 | 151 | 0.2 | 0.44 |
20 | 394 | 0.51 | 0.95 |
21 | 526 | 0.68 | 1.63 |
22 | 846 | 1.1 | 2.73 |
23 | 925 | 1.2 | 3.93 |
24 | 1,321 | 1.71 | 5.64 |
25 | 2,236 | 2.9 | 8.55 |
26 | 1,828 | 2.37 | 10.92 |
27 | 2,076 | 2.69 | 13.61 |
28 | 2,600 | 3.37 | 16.98 |
29 | 1,937 | 2.51 | 19.5 |
30 | 4,130 | 5.36 | 24.85 |
31 | 1,736 | 2.25 | 27.11 |
32 | 3,203 | 4.16 | 31.26 |
33 | 1,983 | 2.57 | 33.83 |
34 | 2,309 | 3 | 36.83 |
35 | 4,704 | 6.1 | 42.93 |
36 | 2,343 | 3.04 | 45.97 |
37 | 2,032 | 2.64 | 48.61 |
38 | 2,859 | 3.71 | 52.32 |
39 | 1,959 | 2.54 | 54.86 |
40 | 4,437 | 5.76 | 60.61 |
41 | 1,525 | 1.98 | 62.59 |
42 | 2,566 | 3.33 | 65.92 |
43 | 1,608 | 2.09 | 68.01 |
44 | 1,719 | 2.23 | 70.24 |
45 | 4,199 | 5.45 | 75.69 |
46 | 1,780 | 2.31 | 77.99 |
47 | 1,752 | 2.27 | 80.27 |
48 | 2,390 | 3.1 | 83.37 |
49 | 1,671 | 2.17 | 85.54 |
50 | 2,619 | 3.4 | 88.93 |
51 | 1,316 | 1.71 | 90.64 |
52 | 1,673 | 2.17 | 92.81 |
53 | 1,030 | 1.34 | 94.15 |
54 | 1,014 | 1.32 | 95.46 |
55 | 812 | 1.05 | 96.52 |
56 | 595 | 0.77 | 97.29 |
57 | 448 | 0.58 | 97.87 |
58 | 454 | 0.59 | 98.46 |
59 | 266 | 0.35 | 98.8 |
60 | 367 | 0.48 | 99.28 |
61 | 90 | 0.12 | 99.4 |
62 | 106 | 0.14 | 99.53 |
63 | 62 | 0.08 | 99.61 |
64 | 40 | 0.05 | 99.67 |
65 | 78 | 0.1 | 99.77 |
66 | 23 | 0.03 | 99.8 |
67 | 19 | 0.02 | 99.82 |
68 | 17 | 0.02 | 99.84 |
69 | 13 | 0.02 | 99.86 |
70 | 29 | 0.04 | 99.9 |
71 | 4 | 0.01 | 99.9 |
72 | 3 | 0 | 99.91 |
73 | 4 | 0.01 | 99.91 |
74 | 5 | 0.01 | 99.92 |
75 | 2 | 0 | 99.92 |
76 | 1 | 0 | 99.92 |
77 | 1 | 0 | 99.92 |
78 | 1 | 0 | 99.93 |
79 | 1 | 0 | 99.93 |
80 | 5 | 0.01 | 99.93 |
82 | 3 | 0 | 99.94 |
83 | 1 | 0 | 99.94 |
84 | 1 | 0 | 99.94 |
85 | 1 | 0 | 99.94 |
87 | 1 | 0 | 99.94 |
88 | 1 | 0 | 99.94 |
90 | 1 | 0 | 99.95 |
95 | 42 | 0.05 | 100 |
Total | 77,082 | 100 |