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: replace a set of numbers with a second set of numbers


From   Tyler Frazier <[email protected]>
To   [email protected]
Subject   Re: st: replace a set of numbers with a second set of numbers
Date   Fri, 23 Jul 2010 20:57:38 -0400

T,

Thank you so much for the code, I think my brain is a bit fried these
days -- and I just couldnt see a merge for some reason  ...

merge m:1 id1 using "C:\Documents and Settings\admin\Desktop\zone_id.dta"

rename id1 id2

merge m:1 id2 using "C:\Documents and Settings\admin\Desktop\zone_id.dta"

and I picked up a few tricks from the rest of your code.

Big thanks!
Ty


On Thu, Jul 22, 2010 at 8:47 PM, Tirthankar Chakravarty
<[email protected]> wrote:
> Tyler,
>
> I am assuming the existence of a separate lookup file of the form you report?
> objectid        zone_id
> 1       =      201005050010
> 2       =      201005050020
> 3       =      201005050040
> 4       =      201005050030
> 5       =      201005050060
> 6       =      201005050050
> 7       =      201005050100
> 8       =      201005050110
> 9      =      201005050070
> 10      =      201005050130
>
> ...
>
> 279       =     201025050010
> 280       =     201025050080
>
> In which case, try the following (brute force) example:
> **********************************
> // generate data of the type reported
> clear*
> set obs 280
> g ego = _n
> forv i=1/280 {
>        g alter`i' = `i'
> }
> reshape long alter, i(ego) j(alternum)
> drop if ego==alter
> tostring ego alter, replace
> g ego_alter = ego+"-"+alter
> g randomdata = runiform()
> drop ego alter
> tempfile intermediate
> save `intermediate', replace
>
> // generate a separate lookup file
> clear
> set obs 280
> g object_id = _n
> g zone_id = ceil(runiform()*10e6)
> tempfile lookup
> save `lookup', replace
>
> // merge the zone_ids in
> use `intermediate', clear
> drop alternum
> split ego_alter, generate(id) parse("-") destring
> preserve
> use `lookup', clear
> rename object_id id1
> rename zone_id id1_zone_id
> save `lookup', replace
> restore
> merge m:1 id1 using `lookup', gen(id1_merge)
> preserve
> use `lookup', clear
> rename id1 id2
> rename id1_zone_id id2_zone_id
> save `lookup', replace
> restore
> merge m:1 id2 using `lookup', gen(id2_merge)
>
> // clean up
> drop *merge id?
> tostring *zone*, replace
> g egozone_alterzone =  id1_zone_id+"-"+id2_zone_id
> drop  id1_zone_id id2_zone_id
> browse
> **********************************
>
> T
>
> 2010/7/23 Tyler Frazier <[email protected]>:
>> I want to replace a set of numbers (1 to 280) with another set of
>> numbers (201005050010 to ~201025050080)
>>
>> the file has the time and distance between each of the 280 different
>> points (78,400 observations)
>>
>> 1 - 1
>> 1 - 2
>> 1 - 3
>> 1 - 4
>> ...
>> 1 - 280
>> ...
>> 279 - 279
>> 279 - 280
>>
>> but the set of numbers was exported with a default setting and I need
>> to replace each number such that
>>
>> objectid        zone_id
>> 1       =      201005050010
>> 2       =      201005050020
>> 3       =      201005050040
>> 4       =      201005050030
>> 5       =      201005050060
>> 6       =      201005050050
>> 7       =      201005050100
>> 8       =      201005050110
>> 9      =      201005050070
>> 10      =      201005050130
>>
>> ...
>>
>> 279       =     201025050010
>> 280       =     201025050080
>>
>> can someone make a suggestion for me regrading this? Im having
>> difficulty figuring it out in Stata.
>>
>> Thanks,
>> Ty
>> *
>> *   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/
>>
>
>
>
> --
> To every ω-consistent recursive class κ of formulae there correspond
> recursive class signs r, such that neither v Gen r nor Neg(v Gen r)
> belongs to Flg(κ) (where v is the free variable of r).
>
> *
> *   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