glarys
glarys

Reputation: 131

Split sample in Stata

I have a variable X containing 3100 values. I need to split X into variable Y and Z. Y containing 1500 first values of X and Z containing the rest of X. I'm not sure whether it works with

split X

or any other code

Upvotes: 0

Views: 688

Answers (1)

Nick Cox
Nick Cox

Reputation: 37208

Did you try it?

split is for splitting strings and for splitting them into parts according to their contents.

You appear to want something like separate X, by(_n <= 1500) followed by renaming if you wish. Two generate statements would also work fine.

Upvotes: 1

Related Questions