Dear STATA users,
I have been trying to write a STATA code as described in the statement below but failed, I need a help from you.
Statement: Create code in Stata that loops through each variable in the dataset, captures the total number of observations for that variable, the number of missing observations, the minimum and the maximum, and saves the result in a table or matrix. Export that table into csv.
Here is an example of the dataset:
hhid age v236 v237 v238 v240 v241 v242
1001 32 "" "yes" "yes" "no" "yes" "no"
1001 32 "" "yes" "yes" "no" "yes" "no"
1001 32 "" "yes" "yes" "no" "yes" "no"
1002 32 "" "yes" "yes" "yes" "no" "no"
1002 32 "" "yes" "yes" "yes" "no" "no"
1003 30 "" "no" "yes" "yes" "yes" "no"
1003 30 "" "no" "yes" "yes" "yes" "no"
1004 68 "" "no" "no" "no" "no" "no"
1004 68 "" "no" "no" "no" "no" "no"
1004 68 "" "no" "no" "no" "no" "no"
1005 28 "no" "yes" "yes" "yes" "yes" "no"
1005 28 "no" "yes" "yes" "yes" "yes" "no"
1006 36 "" "" "" "" "" ""
1007 66 "" "no" "yes" "no" "yes" "no"
1008 52 "" "yes" "no" "no" "yes" "no"
1008 52 "" "yes" "no" "no" "yes" "no"
1008 52 "" "yes" "no" "no" "yes" "no"
1009 37 "" "yes" "yes" "yes" "no" "no"
1010 45 "" "yes" "yes" "yes" "yes" "no"
1010 45 "" "yes" "yes" "yes" "yes" "no"
1010 45 "" "yes" "yes" "yes" "yes" "no"
1011 25 "" "yes" "yes" "yes" "yes" "no"
1011 25 "" "yes" "yes" "yes" "yes" "no"
1012 25 "" "" "" "" "" ""
1013 20 "" "no" "yes" "no" "no" "no"
1013 20 "" "no" "yes" "no" "no" "no"
1014 32 "" "" "" "" "" ""
1015 31 "" "no" "yes" "no" "no" "no"
1015 31 "" "no" "yes" "no" "no" "no"
1015 31 "" "no" "yes" "no" "no" "no"
1016 24 "" "" "" "" "" ""
1017 20 "" "no" "no" "no" "no" "no"
1018 23 "" "" "" "" "" ""
1018 23 "" "" "" "" "" ""
1019 45 "" "yes" "yes" "no" "yes" "no"
1019 45 "" "yes" "yes" "no" "yes" "no"
1019 45 "" "yes" "yes" "no" "yes" "no"
1020 70 "" "" "" "" "" ""
1021 33 "no" "yes" "yes" "no" "no" "no"
1021 33 "no" "yes" "yes" "no" "no" "no"
1021 33 "no" "yes" "yes" "no" "no" "no"
1022 40 "" "no" "no" "no" "yes" "no"
1022 40 "" "no" "no" "no" "yes" "no"
1022 40 "" "no" "no" "no" "yes" "no"
1023 24 "" "no" "yes" "no" "yes" "no"
1024 23 "no" "no" "yes" "no" "yes" "no"
1024 23 "no" "no" "yes" "no" "yes" "no"
1025 27 "" "yes" "no" "yes" "no" "no"
1026 21 "" "" "" "" "" ""
1027 21 "" "no" "no" "yes" "no" "no"
Thanks.
Methode T.
0 Response to Loops in STATA
Post a Comment