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: set obs by level (of multiple variables)?


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: set obs by level (of multiple variables)?
Date   Thu, 17 Jan 2013 15:53:29 +0000

The syntax diagram for -set- does not indicate support for -by:- and

1. Whatever is not permitted should be considered forbidden.

2. Less gnomically, there is a really good reason for this. In
essence, -set- is about global settings, and even if what you are
asking for makes sense -- as it does here -- -set- and -by:- don't mix
naturally.

See help for -expand-, -expandcl-, -expandby- (SSC).

bysort stage sex : gen last = _n == _N
expand 2 if last
sort stage sex
... if last

On Thu, Jan 17, 2013 at 3:08 PM, Tim Evans <Tim.Evans@wmciu.nhs.uk> wrote:

> I'm trying to insert extra observations in my dataset - I've calculated survival and wish to graph the results but the data start from less than 100%, but I'd like the graph to graph from time 0 and thus 100%. My dataset is split by gender and stage so I need something that inserts an observation for say males & stage 1, males stage 2, females stage 1 and females stage 2.
>
> Unfortunately, while this will provide me with an observation
>
> set obs `=_N+1' it does not support this:
>
> bysort stage sex: set obs `=_N+1'
>
> Does anyone have an idea how I might do this in Stata 11.2?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index