<>
As Miguel correctly points out, the codes could be strings, so here is a
solution for both data types...
***
clear*
input isiccode str4 strisidcode
4354 "4354"
6512 "6512"
1965 "1965"
9843 "9843"
1234 "1234"
end
compress
list, noobs
//for numeric codes
gen twodigit=int(isiccode/100)
//for string codes
gen strtwodigit=substr(strisidcode, 1,2)
list, noobs
***
HTH
Martin
_______________________
----- Original Message -----
From: "Martin Weiss" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 21, 2009 11:06 PM
Subject: st: Re: keeping first digits in number
<>
***
clear*
input isiccode
4354
6512
1965
9843
1234
end
compress
list, noobs
gen twodigit=int(isiccode/100)
l
***
HTH
Martin
_______________________
----- Original Message -----
From: "Juan Julio Gutierrez" <[email protected]>
To: <[email protected]>
Sent: Thursday, May 21, 2009 10:56 PM
Subject: st: keeping first digits in number
Hello all
I am working with ISIC codes at the four digit level, but want to perform
descriptives at the two digit level.
Ideas on how to create a variable that delete the last 2 digits of the 4
digit categories but keeps the first two?
Thank you
JJ
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/