|  |  | 
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Generating a vector
Dear Phil,
I have resent my message with subject line "generating a matrix, adding 
values in a column"
I experimented with the following that you suggested
. mat a = J(1,5,23)
. mat li a
which produced the value 23 in all 5 columns
Instead I would like to generate 326 rows with say 3 columns with each 
column having a different value repeated 326 times.
    c1 c2 c3
r1  10   22  53
r2  10   22  53
r3  10   22  53
r4  10   22  53
Is there any way whereby these columns can be given a name?
Regards,
Gauri
From: Phil Schumm <[email protected]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: st: Generating a vector
Date: Sat, 20 May 2006 16:08:26 -0500
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 don't understand; if the vector is 1 x 326, and if each value will  be 
repeated 326 times, then you'll need 4 separate vectors to hold  the 4 
values, no?
I guess the first step would be to generate an empty(?)/null vector  and 
then fill it with values for each of the inputs.
I'm sorry, but there's really not enough here to give much of an  answer.  
If you want to generate a matrix containing a constant  value, then you 
want to use the function J(), like so:
. mat a = J(1,5,23)
. mat li a
a[1,5]
    c1  c2  c3  c4  c5
r1  23  23  23  23  23
Note that -help matrix- (followed by clicking on "matrix functions")  would 
have also given you this answer.  So, the first "meta-answer"  to your 
question is really a suggestion that if you want to work with  matrices in 
Stata, you should spend some time with [P] matrix.
In addition, it looks as though your immediate question is just the  first 
step in what is really a larger problem you are trying to  tackle.  If this 
is true, then it is really better to ask "I'm trying  to do X and I think Y 
is a good place to start, but I'm having  problems" rather than just asking 
"I can't figure out how to do Y".   There are at least two reasons for 
this.  First, Y may not be the  best way to start, so you should give 
people on the list an  opportunity to tell you that; after all, getting you 
started on the  right path is half the battle.  Second, if you are having 
problems  with Y, there's a good chance you will also have problems with  
subsequent steps, and it's a lot more efficient for everyone involved  if 
you just give your whole problem up front and let people help you  with the 
entire thing.  Moreover, this makes for much more useful  list archives 
(i.e., those who come along later with the same problem  will be able to 
find the answer in a single posting or two, instead  of spread across 
many).
That said, your question suggests that you are working on a economic  
problem, and not being an economist, I'm afraid others may need to  help 
you solve it (but I too will read their answers and learn).  I  apologize 
to the economists on the list for having volunteered your  services ;)
-- Phil
*
*   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/