Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Using svy with by


From   <[email protected]>
To   <[email protected]>
Subject   st: Using svy with by
Date   Tue, 4 Aug 2009 11:14:16 +0100

Hi all,
 
I'm trying to find a way around a problem. The code below results in an error since svy cannot by combined with by. I cannot think of another way to get the equivalent result I need, however, since the mean I'm attempting to calculate must be run using svy.
 
Any ideas?
 
Code:

foreach varname of varlist `PAYMENTVARS' {
generate `varname'PANAVG = 0
  by DUPERSID PURCHRD, sort: svy: replace `varname'PANAVG = mean(`varname')
  by DUPERSID PURCHRD: keep if _n==_N
  drop `varname'
  }
 
 
Error:

svy may not be combined with by
r(190);

 

Regards,

A


Please access the attached hyperlink for an important electronic communications disclaimer: http://www.lse.ac.uk/collections/secretariat/legal/disclaimer.htm

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index