## Sample

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

startz
Non-normality and collinearity are NOT problems!
Posts: 3371
Joined: Wed Sep 17, 2008 2:25 pm

### Re: Sample

I'm afraid I'm stumped too.

EViews Matt
EViews Developer
Posts: 290
Joined: Thu Apr 25, 2013 7:48 pm

### Re: Sample

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 agesmpl @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`

mpsc19
Posts: 24
Joined: Mon Jul 10, 2017 8:41 am

### Re: Sample

EViews Matt wrote: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 agesmpl @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"

EViews Matt
EViews Developer
Posts: 290
Joined: Thu Apr 25, 2013 7:48 pm

### Re: Sample

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 tmpstom(a5, tmp)string codes = ""for !i = 1 to @rows(tmp)   if @instr(codes, tmp(!i)) = 0 then      codes = codes + tmp(!i) + " "   endifnextdelete tmp`