Em 25 de março de 2010 Allin Cottrell <allincottrell(a)gmail.com> escreveu:

Henrique wrote:
>
> > In a time series context, how may I insert variable labels (from a .txt
> > file) into a dataset via a script or console? I know that using the GUI I
> > can choose "Data -> Variable labels" and then select the .txt file with the
>
>
>
> > descriptions.
>
> A couple of recent tweaks in CVS (to the sscanf function and the setinfo
> command) make this a bit easier than before. Example follows, where we
> assume that labels.txt contains one variable label per line, for each
>
>
>
> of the substantive variables in the dataset.
>
> <script>
> nulldata 10
>
> series x1 = normal()
> series x2 = normal()
> series x3 = normal()
> series x4 = normal()
>
> string labeltext = readfile("labels.txt")
>
>
>
> string vname, label
>
> loop i=2..5 -q
>   sscanf(labeltext, "%63[^\n]", label)
>   setinfo i -d "@label"
>   labeltext = labeltext + strlen(label) + 1
> endloop
> </script>
>
> Thanks for the script. I will try to use it inside my script.

(BTW, apologies for not replying "properly"; my university email account
>
>
>
> is screwed up at the moment so I'm resorting to gmail.)
>
> Don't worry! You're almost as fast as usual. ;-)

Best regards,
Henrique
Em 25 de março de 2010 Allin Cottrell <allincottr...@gmail.com> escreveu:

Henrique wrote:
> In a time series context, how may I insert variable labels (from a .txt
> file) into a dataset via a script or console? I know that using the GUI I
> can choose "Data -> Variable labels" and then select the .txt file with the
> descriptions.

A couple of recent tweaks in CVS (to the sscanf function and the setinfo
command) make this a bit easier than before. Example follows, where we
assume that labels.txt contains one variable label per line, for each
of the substantive variables in the dataset.

<script>
nulldata 10

series x1 = normal()
series x2 = normal()
series x3 = normal()
series x4 = normal()

string labeltext = readfile("labels.txt")
string vname, label

loop i=2..5 -q
sscanf(labeltext, "%63[^\n]", label)
setinfo i -d "@label"
labeltext = labeltext + strlen(label) + 1
endloop
</script>
Thanks for the script. I will try to use it inside my script.

(BTW, apologies for not replying "properly"; my university email account
is screwed up at the moment so I'm resorting to gmail.)
Don't worry! You're almost as fast as usual. ;-)

Best regards,
Henrique

Reply via email to