[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Splitting string variables without parse strings

From   Gianluca Cafiso <>
Subject   Re: st: Splitting string variables without parse strings
Date   Fri, 08 May 2009 15:27:37 +0200


you should be able to make it trough " gen ...=substr(...)".


Quoting Ben Carpenter <>:

Dear statalisters,

I have got a problem splitting one string variable into four new stringvariables each containing a part i.e. 1digit

of the former 4digit string variable.

My strings look like "103A" or "009X" (without the "") i.e. I have got 4 digit codes which contain numbers and


I want to generate four new variables each consisting of one digit of the former 4digit-string variable.

An Example:

sitc(variable name of the 4digit string var):

After the split the data should look like:

sitc_1st_digit	sitc_2nd_digit	sitc_3rd_digit	sitc_4th_digit
1		0		3		A
0		9		X		X

As far as I know, the split command needs characters as parse_strings to know when to "cut" the string. But I don

´t have any parse strings within my 4digit string variable. How can I cope with that? Is there another command(or

combination of commands) apart from "split" which can deal with the problem?

I would very much appreciate help with this tricky problem.

Thank you very much for your help,

Ben C.
Neu: GMX FreeDSL Komplettanschluss mit DSL 6.000 Flatrate + Telefonanschluss für nur 17,95 Euro/mtl.!*
*   For searches and help try:

Gianluca Cafiso
Research Fellow, Economics Department-University of Catania.
Corso Italia 55, Catania, Italy.

tel.:  +39 0957537745

Università di Catania - C.E.A.
Servizio di Posta Elettronica

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index