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

st: RE: RE: RE: RE: RE: Using a SAS like Array procedure in STATA


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: RE: RE: RE: Using a SAS like Array procedure in STATA
Date   Mon, 27 Jun 2005 23:14:09 +0100

Good question. -1 is my mistake. I meant +1, as for 
example your measure of DISTRESS is 4 whenever any 
of the variables concerned is 3. Sorry about that. 

Nick 
n.j.cox@durham.ac.uk 

Winfred Avogo
 
> Thanks your code helped. But may I ask what the -1 represents, just a
> gist about your code.

Nick Cox
 
> This statement is not a definition, but background 
> comment. My point was that I cannot help if you 
> don't trust your own code, as I don't know exactly 
> what you are trying to calculate. 
> 
> My code offers one simplification of your code. 
> 
> gen distress = max(h3sp5, h3sp6, rr_h3sp7, h3sp8, h3sp9, h3sp10,
> rr_h3sp11, h3sp12, h3sp13) - 1 
> 
> may even be right. I can't offer a shorter solution. 
> 
> My guess is that you don't need any Stata emulation 
> of SAS arrays to solve your problem. 
 
Winfred Avogo
  
> > Thanks for assisting Nick. 
> > 
> > My definition of DISTRESS comprises the nine variables 
> outlined asking
> > adolescents a series of questions bothering on 
> psychological distress
> > during the last seven days, e.g. things that bothered them, 
> > inability to
> > shake off blues, difficulty concentrating and being depressed.   
> > 
> > I have reviewed the link on Array but seem not to 
> understand it as it
> > applies to what I am trying to do. Could it be simplified?
  
Nick Cox
 
> > Not being aware of your definition of DISTRESS I can't offer 
> > any checks here. 
>  
> > gen distress = . 
> > replace distress = max(h3sp5, h3sp6, rr_h3sp7, h3sp8, h3sp9, h3sp10,
> > rr_h3sp11, h3sp12, h3sp13) - 1 
> > 
> > looks like one equivalent of your code. 
> > 
> > See also 
> > http://www.stata.com/support/faqs/data/arrays.html
 
Winfred Avogo (modulo deprecated HTML, etc.) 
  
> > I am working on Add health data in Stata 9 and wish to 
> create a single
> > measure of DISTRESS using 9 identified variables all on a 
> > scale of 0-3.
> > I have tried Stata's -generate- and 
> > -replace- command below but did not trust the results I obtained.
> >  
> > generate distress=.
> > replace distress=1 if
> > h3sp5==0|h3sp6==0|rr_h3sp7==0|h3sp8==0|h3sp9==0|h3sp10==0|rr_h
> > 3sp11==0|h
> > 3sp12==0|h3sp13==0
> > replace distress=2 if
> > h3sp5==1|h3sp6==1|rr_h3sp7==1|h3sp8==1|h3sp9==1|h3sp10==1|rr_h
> > 3sp11==1|h
> > 3sp12==1|h3sp13==1
> > replace distress=3 if
> > h3sp5==2|h3sp6==2|rr_h3sp7==2|h3sp8==2|h3sp9==2|h3sp10==2|rr_h
> > 3sp11==2|h
> > 3sp12==2|h3sp13==2
> > replace distress=4 if
> > h3sp5==3|h3sp6==3|rr_h3sp7==3|h3sp8==3|h3sp9==3|h3sp10==3|rr_h
> > 3sp11==3|h
> > 3sp12==3|h3sp13==3
> >  
> > I would be happy if I could obtain assistance to do this more
> > efficiently. Will array code in Stata like is done in SAS be 
> > appropriate here.

*
*   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