Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72764

Keeping observations that start with specific digits

$
0
0
Hello,

How can I keep observations that start with a certain set of numbers. Specifically, I want to keep observations that start with "3344" within a list of mostly 6-digit numbers. I found a previous post (http://www.stata.com/statalist/archi.../msg01191.html) but for some reason these options aren't working. I've tried the following but stata says I’m using invalid syntax.

keep if substr(string(naics02), 1, 2, 3, 4) == "3344"

I then tried using floor but it dropped all of my data (when in fact there are observations that start with 3344):

keep if floor(naics02/10000) == 3344

Please help! Thank you!

Alyse

Viewing all articles
Browse latest Browse all 72764

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>