Hi there!
I am working on extracting information from text data and was wondering if there is a way to count the number of non-missing variables in each row. The following is what my dataset looks like. I would like a variable that shows how many variables are non-empty by row (e.g. 2 in row 1, 2 in row 2, so forth).
One option I considered is to encode the string variables and use egen's -rownonmiss-. However, that seems a bit roundabout. Is there an alternative?
Thanks very much!
Krishna
I am working on extracting information from text data and was wondering if there is a way to count the number of non-missing variables in each row. The following is what my dataset looks like. I would like a variable that shows how many variables are non-empty by row (e.g. 2 in row 1, 2 in row 2, so forth).
One option I considered is to encode the string variables and use egen's -rownonmiss-. However, that seems a bit roundabout. Is there an alternative?
Thanks very much!
Krishna
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str7 var1 str6 var2 str5 var3 "asdfdgf" "" "mnbvc" "" "qwerty" "mnbvc" "" "qwerty" "" "asdfdgf" "qwerty" "mnbvc" "asdfdgf" "qwerty" "mnbvc" end
Comment