Sample

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator

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

Re: Sample

Postby startz » Mon Oct 16, 2017 10:35 am

I'm afraid I'm stumped too.

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

Re: Sample

Postby EViews Matt » Mon Oct 16, 2017 11:37 am

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

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

Re: Sample

Postby mpsc19 » Mon Oct 16, 2017 7:04 pm

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 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"

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

Re: Sample

Postby EViews Matt » Tue Oct 17, 2017 10:56 am

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


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 4 guests