Hello,
How can I take a sample of unique values of a variable, and then filter my dataset according to those drawn values?
That is, assume my variable product contains multiple product identifiers (strings). More than one row of the data is attached to a given product, and different products appear in different frequencies in the data.
(therefore, simply taking a sample of the data itself won't suffice).
How can I take a sample of size N of the product identifiers and then filter the data to keep observations linked to those identifiers that were drawn?
I tried using something with
but didn't know how to use the sample command with a local
Thank you
How can I take a sample of unique values of a variable, and then filter my dataset according to those drawn values?
That is, assume my variable product contains multiple product identifiers (strings). More than one row of the data is attached to a given product, and different products appear in different frequencies in the data.
(therefore, simply taking a sample of the data itself won't suffice).
How can I take a sample of size N of the product identifiers and then filter the data to keep observations linked to those identifiers that were drawn?
I tried using something with
Code:
levelsof product, local(unique_values)
Thank you
Comment