Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: database manipulation


From   Eric Booth <[email protected]>
To   "<[email protected]>" <[email protected]>
Subject   Re: st: database manipulation
Date   Thu, 7 Oct 2010 21:03:43 +0000

<>


*************!

**input some fake data**
clear
inp str12(date site)
"12/3/1979" "Dallas, TX"
"1/1/1975" "Houston,TX"
end

**dates**
g date2 = date(date, "MDY")
format date2 %td
help dates_and_times

**sep city and state**
split site, p(",")
help split

**use trim() function to get rid of extra spaces**
replace site1 = trim(site1)
replace site2 = trim(site2)
help f_trim

**************!

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754




On Oct 7, 2010, at 3:40 PM, Michael Eisenberg wrote:

> Colleagues,
> 
> I have what I hope are a few simple questions regarding a fragmented
> database I'm trying to manipulate in stata.
> 
> 1. Is there a way to convert the following date format (1/1/1975) into
> a date form that stata will recognize?
> 
> 2.  Is it possible to separate a single string field separated by
> commas into 2 separate fields (i.e. Dallas, TX into Dallas in one
> field and TX in another)?  What about if a space was between the two
> fields (i.e. Dallas TX into two fields - one with Dallas and the other
> with TX)?
> 
> Thank you in advance.
> 
> Mike
> *
> *   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index