Statalist The Stata Listserver


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

st: Re: generating a matrix


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: Re: generating a matrix
Date   Mon, 22 May 2006 08:20:49 -0400

describing are ordinary Stata variables. If you really want to repeat scalars 326 times, then

gen input1 = 33.12
gen input2 = 156
gen input3 = 227.8

And if you want the sum of a variable, there are a couple of ways to do it.

egen tot1 = total(input1)

will place the total of all values of input1 (in this case, 326 * 33.12) in a new variable. That is a very wasteful use of memory. You could also do

summarize input1, meanonly
scalar tot1 = r(sum)

which would place the same total into a scalar.

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


On May 22, 2006, at 2:33 AM, Gauri wrote:


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

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