I have naics codes that have six digits, and I want to get the first three digits in each of them and form a new variable named three_digits

I tried using the "gen threedigit=int(Naics_1/1000)" (this gave me a list of zeros in the newly generated variable)

Looking at answers to similar posts, I used "gen three_digit=substr(naics, 1,2,3)" and it was an Invalid Syntax

Thank you.