Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Sergiy Radyakin <serjradyakin@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: dropping matrix columns |

Date |
Thu, 12 Dec 2013 12:03:54 -0500 |

set more off clear matrix A=1,2,.,3,.\ 5,3,.,8,. \ 9,0,.,2,. matrix colnames A=1 2 3 4 5 matrix list A tempname B local r=rowsof(A) forval c=1/`=colsof(A)' { mata st_numscalar("mx",max(st_matrix("A")[.,`c'])) if (mx<.) matrix `B'= nullmat(`B'), A[1..`r',`c'] } matrix A=`B' svmat A list ******* Sergiy Radyakin ************* On Thu, Dec 12, 2013 at 11:56 AM, Nick Cox <njcoxstata@gmail.com> wrote: > -svmat- really is an anomaly. I can remember comments about the end of > the last century, and I am being literal and not exaggerating, that it > was due for an overhaul, which never came. But then came Mata and -- I > am imputing a missing statement here -- the implication is that it is > superseded but remains available so as not to break any existing > programs or do-files. It's not worth any developer time to update > something in that condition. It would be like adding an engine to a > donkey. > > So, the short and general answer is: Don't write anything now using > -svmat-. There will be a much better way to do what you want using > Mata. In particular, check out -putmata- and -getmata-. > > Nick > njcoxstata@gmail.com > > > On 12 December 2013 16:40, <altruist81@gmx.de> wrote: >> Dear Stata Users, >> >> I am using a loop in which many large matrices are created. I want to use (each of) these matrices to create a single new dataset using the -svmat- command. For each of the matrices many of the column names start with a number AND are the columns empty. Since variable names that start with a number are not allowed -svmat- does not work, i.e. I first need to either change get rid of the first numbers in the column names or delete these columns ( I dont need them). >> How can I tell stata to drop all matrix columns for which the name starts with a number OR tell stata to drop all columns in a matrix that are entirely empty? >> >> Many thanks >> >> Darjusch >> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/faqs/resources/statalist-faq/ >> * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: dropping matrix columns***From:*altruist81@gmx.de

**Re: st: dropping matrix columns***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: dropping matrix columns** - Next by Date:
**Re: st: Factors correlated after -predict-... What is going wrong?** - Previous by thread:
**Re: st: dropping matrix columns** - Index(es):