gen lastdigit=real(substr(string(occ),-1,1))
HTH,
Ph
Michael Foster wrote:
good morning,
here's what I'd do -- the original variable is -occ-
gen lastdigit=occ-int(occ/10)*10
that should work--
michael
UNC School of Public Health
Mar�a Paula Cacault wrote:
Dear listers:
I have a variable (occupational code) that takes values 1 to 10000 but
always finishes in 1, 2, 3 or 4 (qualification level). I need to create a
new variable with this last numbers (qualification level) so my new
variable
takes values 1 2 3 and 4 (the original variable has no puncts or commas
separating the figures).
Is there a way to do it?
Thank you very much
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/