Dear All,
I need to sample 40 observations from a dataset of 80 and then reload the full dataset to get the other 40 by dropping the ones in the first group.
Now I need to save the values of "n" variable of these sampled obs, re-import the dataset and drop the observations with n equal to this vector of values.
I thought about 2 ways of performing this task:
1 - save the vector of values in a matrix with putmata and re-importing the dataset
but then I don't know how to drop the observations if n == one of the values in group1
2 - alternatively I thought I could save this vector of values in a local macro by using
after sampling, but I don't know how to store that output in a local.
I've done many attempts without success.
Thanks in advance for the support.
I need to sample 40 observations from a dataset of 80 and then reload the full dataset to get the other 40 by dropping the ones in the first group.
Code:
import excel "...db.xlsx", sheet("...1") firstrow generate n=_n sample 50
I thought about 2 ways of performing this task:
1 - save the vector of values in a matrix with putmata and re-importing the dataset
Code:
putmata group1=(n) clear import excel "...db.xlsx", sheet("...") firstrow generate n=_n
2 - alternatively I thought I could save this vector of values in a local macro by using
Code:
levelsof n
I've done many attempts without success.
Thanks in advance for the support.
Comment