Re: Sample
Posted: Mon Oct 16, 2017 10:35 am
I'm afraid I'm stumped too.
Code: Select all
' Find all children of the desired age
smpl @all if cho03 = 3 and cho06 >= 18 and cho06 <= 30
' Create a string containing all the household codes associated with those children.
string codes = @wjoin(@uniquevals(a5))
' Show only the households with the matching codes.
smpl @all if @instr(codes, a5) <> 0
When I try to make the second step, there is a sign that says: "incorrect numbers of arguments"Hello,
I believe the fundamental problem is that information about a household with children is split across several observations. Without making any assumptions about how the observations for a single household are related (I notice they're two apart in your example, but I don't know if that pattern is always true), you need to (1) identify the household codes for the households with children in the desired age range, and (2) filter/sample by those household codes. For example, assuming all households have a boss (so we don't have to check for a boss):
Code: Select all
' Find all children of the desired age smpl @all if cho03 = 3 and cho06 >= 18 and cho06 <= 30 ' Create a string containing all the household codes associated with those children. string codes = @wjoin(@uniquevals(a5)) ' Show only the households with the matching codes. smpl @all if @instr(codes, a5) <> 0
Code: Select all
svector tmp
stom(a5, tmp)
string codes = ""
for !i = 1 to @rows(tmp)
if @instr(codes, tmp(!i)) = 0 then
codes = codes + tmp(!i) + " "
endif
next
delete tmp