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: RE: number generation
From
Tyler Frazier <[email protected]>
To
[email protected]
Subject
Re: st: RE: number generation
Date
Sun, 30 May 2010 23:27:44 +0200
ok finally got it, for anyone who is interested
*******
bysort plot: gen bldg=_n
gen str3 bldg1 = string(bldg,"%03.0f")
*******
which works with outsheet
On Sun, May 30, 2010 at 10:45 PM, Tyler Frazier <[email protected]> wrote:
> I found this works, but it seems the format option should be in the
> same line with -tostring-
>
> ******
> bysort plot: gen bldg=_n
>
> tostring bldg, gen(bldg1)
>
> format %003s bldg1
> *******
>
>
> On Sun, May 30, 2010 at 10:31 PM, Tyler Frazier <[email protected]> wrote:
>> I came up with this short code based on your recommendation -- the
>> bysort works fine, but I am having problems with the format option,
>> its syntax I believe.
>>
>> *******
>> bysort plot: gen bldg=_n
>>
>> tostring bldg, gen(bldg1) format(%3s)
>> *******
>>
>>
>> On Sun, May 30, 2010 at 7:14 PM, Martin Weiss <[email protected]> wrote:
>>>
>>> <>
>>>
>>> The solution could be as easy as
>>>
>>>
>>> ***********
>>> bysort block: gen bldg=_n
>>> ***********
>>>
>>> See NJC`s http://www.stata-journal.com/sjpdf.html?articlenum=pr0004
>>>
>>>
>>> HTH
>>> Martin
>>>
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Tyler Frazier
>>> Sent: Sonntag, 30. Mai 2010 19:02
>>> To: [email protected]
>>> Subject: st: number generation
>>>
>>> I would like to generate a method to number buildings in sequence, but
>>> restart the sequence in accordance with a group. For example I have
>>> the following nomenclature
>>>
>>> (block) (round) (plot) (bldg)
>>> 005 050 010 xxx
>>> 005 050 020 xxx
>>> 005 050 030 xxx
>>> 005 050 040 xxx ...
>>>
>>> 005 050 150 xxx ...
>>>
>>> 005 060 010 xxx ...
>>>
>>> 010 010 010 xxx ...
>>>
>>>
>>> where xxx represents a unique object identifier. I'm thinking to use
>>> gen or egen with a cond() qualifier, but how to set the parameters for
>>> the unique object identifier such that it returns sets of the
>>> following structure
>>>
>>> 005 050 010 001
>>> 005 050 010 002
>>> 005 050 010 003 ...
>>>
>>> 005 050 010 999
>>>
>>> thank you,
>>> 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/
>>>
>>> *
>>> * 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/