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.
Related Posts with Loops in STATA
Analysing Likert scale outcome variable and how to combine questions into oneHello friends I have a challenge analysing likert scale outcome variable. Allow me share full detail…
Positive and Negative DV Values in Panel Data analysis, potential solutionsis it possible to regress a period average of your DV onto annual values of IVs. My DV is Chinese OF…
Wald test for one-sided hypothesis - strict inequalityI am trying to test a one-sided hypothesis after running a regression to see if the sum of two coeff…
Stata's log-likelihood and likelihood ratio test for gamma GLMI'm trying to make sense of the log-likelihood reported by Stata for a glm with family(gamma), which…
Plotting graphs related to synth (synthetic control)Array Folks, I’m trying to plot some graphs related to command synth in Stata, but I’m not succeedin…
Subscribe to:
Post Comments (Atom)
0 Response to Loops in STATA
Post a Comment