On Thu, 31 Jul 2008, Gordon Hughes wrote:
I can supplement my previous query with a report based on my
experiments, which may be an error or a feature...
The error you're seeing is due to some sort of bad interaction
between setobs and restricting the sample within a function.
Plain setobs by itself seems to do the right thing (except that it
doesn't automatically revert on exit from a function), as in this
example:
<script>
function xpanel (series x)
printf "xpanel: datatype = %d (should be 3)\n", $datatype
genr xunit=$unit
genr time
setobs 1 1 --cross-section
printf "xpanel: datatype = %d (should be 1)\n", $datatype
setobs xunit time --panel-vars
printf "xpanel: datatype = %d (should be 3)\n", $datatype
end function
open greene14_1
printf "caller: datatype = %d (should be 3)\n", $datatype
xpanel(C)
printf "caller: datatype = %d (should be 3)\n", $datatype
</script>
Running the above produces:
<output>
caller: datatype = 3 (should be 3)
? xpanel(C)
xpanel: datatype = 3 (should be 3)
xpanel: datatype = 1 (should be 1)
xpanel: datatype = 3 (should be 3)
caller: datatype = 3 (should be 3)
</output>
I'll investigate the "restrict" interaction.
Allin.