On Wed, 30 Oct 2019, Marcin Błażejowski wrote:
On 30.10.2019 15:46, Sven Schreiber wrote:
> Am 30.10.2019 um 10:24 schrieb Marcin Błażejowski:
>> Hi,
>>
>> is it possible to change the ID number of given variable via script?
>>
> Hi Marcin, I don't think so (in general, without deleting other data),
> because they are contiguous numbers used for indexing. Why do you want
> to do that? Series names or named lists should typically be all you
> need. (in theory)
It's tough to explain, but in short: we have database with houndrets of
series retrived from dbnomics, but after downloading we need to tune
some of them (interpolation, filtering and so on). We want to have a
tunned series next the original one, but all tunning staff we want to
run _after_ downloading the whole database. So, setting variable ID via
script would help us.
There's no command or function that specifically targets this
operation, but it's fairly simple to re-order the series in a
dataset via lists -- which can be treated as vectors (of series ID
numbers) for manipulation -- plus the "store" and "open" commands.
Here's an example. Suppose we want to move the COLLEGE series from
ID 9 to ID 2 in Ramanathan dataset 4-10:
<hansl>
open data4-10
list L = dataset
newpos = 2
oldpos = varnum(COLLEGE)
matrix mL = L
tmp = mL[newpos]
mL[newpos] = oldpos
mL[oldpos] = tmp
L = mL
store reordered.gdt L
open reordered.gdt
</hansl>
Allin