I can supplement my previous query with a report based on my
experiments, which may be an error or a feature. A skeleton example
is as follows:
function xpanel(x)
genr dtest1=$datatype
print dtest1
# Should print 3.000 for panel data
genr xunit=$unit
genr time
setobs 1 1 --cross-section
genr dtest2=$datatype
print dtest2
# Should print 1.000 as data is now cross-section
smpl ok(x) --restrict
...
return series y
setobs xunit time --panel-vars
genr dtest3=$datatype
print dtest3
# Should print 3.000 for panel data
end function
Now call xpanel using a dataset that has been defined as a panel dataset:
genr test1=$datatype
print test1
# Should print 3.000 for panel data
series y = xpanel(x)
genr test2=$datatype
print test2
# Should print 3.000 for panel data but actually the result is 1.000
What is happening is that it is possible to redefine the datatype
from panel to cross-section within the function and operate on the
(sampled) cross-section data. Further, the setobs command at the end
appears to allow you to go back to the original panel
structure. However, that does not get stick when you goes back to
the original calling routine and you are left with cross-section data
at the higher level .
Gordon