Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: create a vector from observations


From   "Rajesh Tharyan" <[email protected]>
To   <[email protected]>
Subject   st: create a vector from observations
Date   Wed, 8 Feb 2006 02:11:51 -0000

Hi,


I have a data set of companies and sales for each of the 12 months of the
year

The dataset looks like this

Co�� �month �������sales
1��������� 1��������� 100
1��������� 2��������� 50
1��������� 3��������� 200
1��������� 4��������� 15


I take the mean of the sales in the first two months (only for the first two
months) and generate a variable X �
Which is the difference between this mean sales and the actual sales for
each month after the second month. 

The final data set should look like this.

Co�� �month ������sales�� meansales����� X
1��������� 1����� 100���������� 75������� .
1��������� 2������50������ ���� 75������� .
1��������� 3����� 200����� ���� 75�������125
1��������� 4������15������� ��� 75��������-60


1. Is there a simple way to do this???

2. Instead of creating a variable meansales can I store the value as a
scalar say "m"and proceed with the calculation as gen X=sales-m if month>2?

3. Also Suppose I had several companies would I be able to create a vector
of these means and use that vector to generate the values of X for each
month>2 for each company?

Any help appreciated...
Thanks in advance

Regards
Rajesh Tharyan

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