Statalist


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

st: Splitting string variables without parse strings


From   "Ben Carpenter" <b.carpenter@gmx.de>
To   statalist@hsphsun2.harvard.edu
Subject   st: Splitting string variables without parse strings
Date   Fri, 08 May 2009 15:19:42 +0200

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 

letters.

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):
103A
09XX

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.!* http://dslspecial.gmx.de/freedsl-surfflat/?ac=OM.AD.PD003K11308T4569a
*
*   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/



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