Page 2 of 2

Re: Sample

Posted: Mon Oct 16, 2017 10:35 am
by startz
I'm afraid I'm stumped too.

Re: Sample

Posted: Mon Oct 16, 2017 11:37 am
by EViews Matt
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

Re: Sample

Posted: Mon Oct 16, 2017 7:04 pm
by mpsc19
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
When I try to make the second step, there is a sign that says: "incorrect numbers of arguments"

Re: Sample

Posted: Tue Oct 17, 2017 10:56 am
by EViews Matt
I don't have a copy of EViews 7 handy, but I now realize @wjoin and @uniquevals probably weren't in that version. You can replace that second statement with something equivalent:

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