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

st: RE: converting lists to matrix


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: converting lists to matrix
Date   Thu, 5 May 2005 22:47:27 +0100

shuffle 1/10, num 
mat input shuffled = (`r(list)')

Nick 
[email protected] 

> -----Original Message-----
> From: Nick Cox 
> Sent: 05 May 2005 20:04
> To: '[email protected]'
> Subject: RE: converting lists to matrix
> 
> 
> -makematrix- is a user-written program too. 
> Both -makematrix- and -shuffle- are on SSC. 
> 
> -makematrix- does make matrices, but not using 
> the kind of building blocks you provide. It is 
> expecting a variable list in the place where 
> you put 1/10. That is explicit in the syntax. 
> 
> You want something like 
> 
> mat shuffled = J(10,1,0) 
> shuffle 1/10, num noisily 
> forval i = 1/10 { 
> 	mat shuffled[`i',1] = `: word `i' of `r(list)''
> } 
> 
> Nick 
> [email protected] 
> 
> Indranil Majumdar
>  
> > I want to shuffle a list and save the result in a matrix. I 
> tried the
> > following.
> > 
> > . local var "1/10"
> > 
> > . shuffle `var',num noisily
> > 2 10 4 5 9 7 3 1 6 8
> > 
> > . makematrix,from(r(list)):shuffle `var',num
> > 1 invalid name
> > r(198);
> > 
> > I use the user-written -shuffle- command but when I use it 
> > with -makematrix-
> > it doesn't work.
> > I guess I am missing something very basic. Could somebody help ?
> 

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