I have a multiple cross-sectional dataset, where I am trying to create the following index:
Dit = (Sum all dit until k)/Kt
In other words, sum the values for all d variables and then divide by the number d variables for that year.
In my dataset, i have 4 variables that i need to look at but for some years only three or two are present so to calculate my index I don't want to just include individuals that had all four. I don't want them to be treated as missing. Instead, i want the aggregated variables to be divided by say 3 instead of 4 if only 3 variables are present. How do i go about creating this Kt?
My four variables are: racmar, racpeers, racpres and racseg. They are byte variables (not string) and are non binary.
Related Posts with How to count the number of relevant variables present for an individual
Multiply and add Code: * Example generated by -dataex-. For more info, type help dataex clear input float(time accp …
Ordering legend only in graphI am trying to order the legend with the better outcome group up top in the legend and the worse out…
cluster/village fix effectsDear Stata users, I am trying to estimate the impact of water quality on child health in 3 Asian co…
Reshaping data from wide to longWhen I try to reshape I keep getting this error r(111) no xij variables found You typed something li…
Draw a stratified random sampleHi, I am working with a survey where I have information at the individual and household levels. I s…
Subscribe to:
Post Comments (Atom)
0 Response to How to count the number of relevant variables present for an individual
Post a Comment