OK, now for a more useful answer!
On Thu, 31 Jul 2008, Gordon Hughes wrote:
[ function slightly trimmed ]
function xpanel(x)
genr xunit=$unit
genr time
setobs 1 1 --cross-section
smpl ok(x) --restrict
...
return series y
setobs xunit time --panel-vars
end function
To get this right you have to respect the nesting of "setobs" and
"smpl --restrict". I hadn't fully realized this, and some work on
the manual is needed. But anyway, the desired pattern is
setobs ... # change data structure
smpl ... # restrict sample
smpl full # unrestrict sample
setobs ... # restore original structure
Or in relation to your example:
function xpanel(x)
genr xunit=$unit
genr time
setobs 1 1 --cross-section
smpl ok(x) --restrict
...
return series y
smpl full # <- IMPORTANT
setobs xunit time --panel-vars
end function
Allin