Statalist


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

st: AW: RE: text to columns


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: RE: text to columns
Date   Tue, 17 Nov 2009 21:47:30 +0100

<> 

-subinstr- does need a fourth argument, though. It could be a missing ".",
but without it, the code won`t work...



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Levy, Douglas
E., Ph.D.
Gesendet: Dienstag, 17. November 2009 21:35
An: statalist@hsphsun2.harvard.edu
Betreff: st: RE: text to columns

Here is one idea:

gen newvar=subinstr(varold,"_"," ")
replace newvar=subinstr(newvar,"-"," ")
foreach i of numlist 1/4 {
	gen var`i'=word(newvar,`i')
	}


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Keith Dear (home)
Sent: Tuesday, November 17, 2009 3:27 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: text to columns

Is there a utility to turn a string variable with values like 
"rs1805005_chr16_88513145-88513"
into four variables (or whatever it takes) rs1805005, chr16, 88513145, 
88513 ?
A colleague tells me "Excel is easy using Text to columns and following 
the prompts, but it irritates me not to be able to do it in Stata!"
(btw I consider it a minor personal victory that the people I work with, 
some of them, sometimes, no longer write STATA.)
kd

-- 
Dr Keith Dear
Senior Fellow
National Centre for Epidemiology and Population Health
ANU College of Medicine, Biology and Environment
Building 62, cnr Mills and Eggleston Roads
Australian National University
Canberra ACT 0200 Australia 

T: 02 6125 4865
F: 02 6125 0740
M: 0424 450 396
W: nceph.anu.edu.au/Staff_Students/staff_pages/dear.php

CRICOS provider #00120C
http://canberragliding.org/

*
*   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/


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the
e-mail
contains patient information, please contact the Partners Compliance
HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in
error
but does not contain patient information, please contact the sender and
properly
dispose of the e-mail.


*
*   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/



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