On Sat, 29 Feb 2020, Riccardo (Jack) Lucchetti wrote:
On Sat, 29 Feb 2020, Artur Tarassow wrote:
> Hi all,
>
> I am bit puzzled about the following behaviour. Even though, the sample is
> restricted to "t>3" obs. only, the strvals() function returns the
distinct
> string-values of series x of the full data set. Is this intended, or a bug?
> I use latest git version on Ubuntu 19.04.
>
> <hansl>
> clear
> set verbose off
> nulldata 6 -p
> genr time
> series x = 1
> smpl time > 3 --restrict
> x = 2
> smpl full
>
> strings names = defarray("A", "B")
> stringify(x, names)
>
> eval strvals(x) # shows ["A", "B"]
> smpl time > 3 --restrict
> eval strvals(x) # still shows ["A", "B"]
> </hansl>
I would say that's intended, since the "strvals" are a property of
the data series, irrespective of the current sample selection.
I agree with Jack. It's inherent that strvals() gives access to a
property of an entire data series. If you have a use case for
obtaining the set of strings associated with the values of a string
variable over a particular sub-sample that can be done (left as an
exercise, but not a terribly difficult one), but it's not the job of
strvals().
Allin