Using a series that's assigned inside a procedure
Posted: Wed Feb 24, 2016 11:51 am
I have a procedure that builds a dataset and returns it as a hash[series]. Outside the procedure, I can access the dataset by referring to the hash directly, but if I try to set a series using those data, the set statement returns a series with no data. For example
outputs
Referring to %data("c") works just fine, so I know that's working, but why isn't the SET instruction working? As a bit of background, I use a procedure like this to build a dataset once (and therefore only read the component datasets from the filesystem once), and then use that dataset in another procedure that requires numerous iterations.
Code: Select all
calendar(q) 1950 1
allocate 2010:4
procedure builddata
option integer beginsamp 1969:1
option integer endsamp 2002:4
declare hash[series] %data
set %data("c") beginsamp endsamp = t
end
@builddata
statistics %data("c")
set s = %data("c")
statistics s
Code: Select all
calendar(q) 1950 1
allocate 2010:4
procedure builddata
(01.0008) option integer beginsamp 1969:1
(01.0027) option integer endsamp 2002:4
(01.0046) declare hash[series] %data
(01.0046) set %data("c") beginsamp endsamp = t
(01.0099) end
@builddata
statistics %data("c")
Statistics on Series
Quarterly Data From 1969:01 To 2002:04
Observations 136
Sample Mean 144.500000 Variance 1552.666667
Standard Error 39.403892 SE of Sample Mean 3.378856
t-Statistic (Mean=0) 42.765956 Signif Level (Mean=0) 0.000000
Skewness 0.000000 Signif Level (Sk=0) 1.000000
Kurtosis (excess) -1.200000 Signif Level (Ku=0) 0.005378
Jarque-Bera 8.160000 Signif Level (JB=0) 0.016907
set s = %data("c")
statistics s
Statistics on Series S
Quarterly Data From 1950:01 To 2010:04
Observations 244
Sample Mean 1.000000 Variance 0.000000
Standard Error 0.000000 SE of Sample Mean 0.000000
t-Statistic (Mean=0) NA Signif Level (Mean=0) NA