Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72787

How to count observations if cell contains string (but not a specific string)

$
0
0
Hey,

I am working on a household-level panel data set, and we asked the name of each household member (string) and then the final household count (numeric). I want to create a new variable that counts the names of the household members and compare it to our household count variable. I want to check whether cells contain names so that I can kick out observations that have a mismatch between the reported household size and those that did not provide us with all the names of the household members. We counted up to 11 household members.

I could only find the regexm function, but that requires that I specify the string variable (e.g. 'a' in name) but I only care that the cell is not empty. It's really just like Excel's CountA(X1:X10) function.

Thanks so much for your help.

Best, Claudia
HH_member_1 HH_member_2 HH_member_3 … HH_member_11 HH_count HH_count_check
Maria Jon Liz 3 Count of (Maria+Jon+Liz)

Viewing all articles
Browse latest Browse all 72787

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>