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

st: Re: How can I find the sum of specific values of a variable?


From   "shigui weng" <[email protected]>
To   <[email protected]>
Subject   st: Re: How can I find the sum of specific values of a variable?
Date   Thu, 20 Nov 2003 20:14:20 -0500

I assume that SIC is numberic, otherwise you can use substr function to
generate gsic, here is the code:

gen gsic=int(sic/100)
table gsic, c(sum gsic) replace name(newds)



Please note, the data set in memory will be replaced by the newds.

Hope it will be of help.

shigui

----- Original Message ----- 
From: "Delis, A." <[email protected]>
To: <[email protected]>
Sent: Thursday, November 20, 2003 4:39 PM
Subject: st: How can I find the sum of specific values of a variable?


> Dear Statalisters
>
> I have a dataset like the following, where the SIC values are in an
ascending order
> SIC EXP
> 2011 667.8039
> 2013 130.8002
> .
> .
> .
> .
>
> 2095 38.90306
> 2098 0.617763
> 2111 249.92
> 2121 3.738577
> 2131 35.32281
> .
> .
> .
> 2298 5.709858
> 2299 39.7519
> .
> .
> etc
>
> What I want to find is the sum of EXP values that have a SIC value
begining with 20, i.e. 667.8039+130.8002+..+38.90306+0.617763
> In others words I have some 4digit SIC data and I want to aggregate them
into  2digit SIC.
>
> Any hint is really appreciated
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index