Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: survey completion "flag"


From   "Marilyn Matevia" <mmatevia@sbcglobal.net>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: survey completion "flag"
Date   Tue, 22 Feb 2005 00:58:19 -0000

This is good stuff.  Thank you.  I think I learned more from this
little exchange than I learned in several weeks of plowing along by
myself!

This list is a terrific resource.
Marilyn M.

--- In statalist@yahoogroups.com, Nick Winter <nw53@c...> wrote:
> Ah yes, I'd forgotten that.
>
> So max(a, b) is NOT the same as cond(a>b,a,b).
>
> --Nick
>
>
>
> At 05:01 PM 2/18/2005 +0000, you wrote:
> >The second problem is well identified.
> >Thanks.
> >
> >The first problem is no problem.
> >
> >max(42, .) is 42, so initialising to
> >missing is safe.
> >
> >This perhaps surprising feature can
> >be rationalised as follows. Given
> >arguments of
> >
> >-1, 0, 1, 2.71828, 3.14159, 42, .
> >
> >would you really want a -max()- function
> >to return missing? It depends on the problem,
> >but it can be forced the other way:
> >
> >gen max = <safe value>
> >foreach v of local varlist {
> >         replace max = cond(`v' == ., ., max(`v', `max')) if !mi
(max)
> >}
> >
> >Nick
> >n.j.cox@d...
> >
> >Nick Winter
> >
> > > Two problems, I think.
> > >
> > > First, because whichislast is initialized as missing,
> > > max(whichislast, `i')
> > > will always return missing.
> > >
> > > Second, if the variables numbers have leading zeros (e.g.
> > > Q001 rather than
> > > Q1), this code won't work.
> > >
> > > Here's a version that also makes the resulting variable
> > > contain the whole
> > > variable name, not just the number:
> > >
> > > gen str whichislast = ""
> > > qui forval i = 1/170 {
> > >          local j : di %03.0f `i'
> > >          replace whichislast = "Q`j'" if Q`j'<.
> > > }
> >
> > > At 09:57 AM 2/18/2005 +0000, you wrote:
> > > >gen whichislast = .
> > > >qui forval i = 1/170 {
> > > >         replace whichislast = max(whichislast, `i') if Q`i'
< .
> > > >}
> > > >
> > > >Nick
> > > >n.j.cox@d...
> > > >
> > > >Marilyn Matevia
> > > >
> > > > > Let me push my luck a little...  If this is the right way
to write
> > > > > the code (to evaluate which of 170 questions is the last
question
> > > > > answered):
> > > > >
> > > > > egen LASTRSP = rlast(Q001-Q170)
> > > > >
> > > > > ... Is there a way to have it return the variable name
> > > (which is the
> > > > > question number) instead of the value of the response?
> > > >
> > > > > > Have a look at -egen, rlast()-.
> > > >
> > > > > > > I am a very new user of Stata, so I apologize in
> > > advance if this
> > > > > is
> > > > > > > a dumb question.  I'm still learning how Stata "thinks"
> > > > > (compared to
> > > > > > > SAS) and can't figure out how to tackle this:
> > > > > > >
> > > > > > > I have a data set of responses to a very long (170
questions)
> > > > > survey
> > > > > > > with many nested skip patterns, and about 2200
respondents.
> > > > > After
> > > > > > > working out the skip codes, I still have many "missing"
> > > > > observations
> > > > > > > for some items, and figure these are due to
> > > incomplete surveys.
> > > > > I
> > > > > > > want to create some kind of "completion flag" to see
which
> > > > > > > respondents make it to the end of the survey, and - if
they
> > > > > don't -
> > > > > > > to see which question is the respondent's last (which
is
> > > > > complicated
> > > > > > > by the skip patterns).
> > > > > > >
> > > > > > > I'm just not coming up with a sensible way to do this
> > > in Stata.
> > > > > Can
> > > > > > > someone point me in the right direction?
> >
> >*
> >*   For searches and help try:
> >*   http://www.stata.com/support/faqs/res/findit.html
> >*   http://www.stata.com/support/statalist/faq
> >*   http://www.ats.ucla.edu/stat/stata/
>
> --------------------------------------------------------
> Nicholas Winter                           607.255.8819 t
> Assistant Professor                       607.255.4530 f
> Department of Government              nw53@c... e
> 308 White Hall            falcon.arts.cornell.edu/nw53 w
> Cornell University
> Ithaca, NY 14853-4601
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/



*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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