Statalist The Stata Listserver


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

st: generating a matrix, adding values in a column


From   "Gauri Khanna" <[email protected]>
To   [email protected]
Subject   st: generating a matrix, adding values in a column
Date   Sun, 21 May 2006 16:46:26 +0000

Dear Kit and Phil and Stata list,

I realised that i was not very clear with my question and my sincere apologies.

I will try and be clear.

1. First of all, both of you are correct. I want to generate the following input price matrix (not vector) with 326 rows: Input1, Input2 and Input3 are values that I have calculated elsewhere and would like to insert these to look like

input1 input2 input3
33.12 156 227.8
33.12 156 227.8
33.12 156 227.8
.
.
.
.
.
until the 326th row.

So I am requesting information on how to generate this matrix.

2. I would like to add the column values from 1 to n(=326). What should I look for in help to generate this. This is what I would like to do

Plot Area
1 2
2 10
3 5.5
4 22
5 3

Generate Totalarea(a scalar?)=2+10+5.5+22+3=47.5

Again, I am sorry for my imprecise message and thank you for your responses, they are nevertheless useful.

Look forward to your response.

Regards,

Gauri


From: Kit Baum <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: st: generating a vector
Date: Sat, 20 May 2006 19:30:04 -0400

On May 20, 2006, at 1:07 AM, Gauri Khanna wrote:
> I would like to generate an 1 x n vector, (n=326 rows) for cross
> sectional data. This is actually an input price vector.
>
> I would then want to fill it with three or four input prices that I
> have computed elsewhere. Hence the same value for each of the
> inputs will be repeated 326 times.

I wonder whether Gauri really wants a vector in the first place. If this is cross-sectional data, and the intent is to do something like multiply an existing variable times an input price, that does not require a vector: it requires a scalar or, more clumsily, a variable. If you have a variable Hours and want to generate Wage*Hours, and wage is a constant, you could just

scalar wage = 12.50
gen wagebill = wage * Hours

or, less efficiently,

gen wage = 12.50
gen wagebill = wage * Hours

Wanting to use a vector sounds a bit like working in a matrix language (e.g. MATLAB or Gauss). Although Stata contains a full- featured matrix language, Mata, doing something like generating the product of factor input prices and quantities does not call for Mata; it can easily be done with Stata's scalars or variables.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


*
* 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/
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

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