On Thu, 23 May 2019, cruz.echevarria(a)ehu.eus wrote:
Dear Gretl users,
I am aware that the following might be trivial, but I am stuck.
Suppose that you have a panel data set whose units are countries
identified by a numerical variable, say "ccode". And you want to
split the sample into two sub-samples: OECD and non-OECD members.
I have tried the following:
genr OECD = 0
if ccode == 1
replace OECD = 1
elif ccode == 4
replace OECD = 1
(...)
end
It does not work. I am aware of the piece of warning in the
Hansl's manual for Stata users (page 32). But, does anyone know
hos I should do this?
If I'm understanding the objective correctly, this is easier than
you're making it!
series OECD = ccode == 1 || ccode == 4
To the right of the first '=' we have a Boolean expression which
evaluates to 1 if the condition (in natural language, "ccode equals
1 or ccode equals 4") is true, 0 otherwise.
The alternation of "ccode == x" values can be continued, split over
more than one line using backslash if necessary.
Allin