Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Use extended functions outside of macro assignment?


From   James Sams <sams.james@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Use extended functions outside of macro assignment?
Date   Wed, 7 Sep 2011 02:45:14 -0500

On Wednesday, September 07, 2011, you wrote:
> The logic of -list- with -if- is like any other command. Consider
> 
> list if 2 == 2
> 
> 2 == 2 is (vacuously) true when considered for observation 1, for
> observation 2, and so on, so every variable and every observation will
> be -list-ed. The same will be true of your syntax. If your condition
> is true, i.e. there is a match, then everything will be listed.

No, you are misunderstanding. Take the latter example, id is a variable, ids is 
a local macro list. The conditional would be re-evaluated for each 
observation's value of the 'id' variable. Same for the regexm example. 
(repasted for reference).

> > Something like this:
> > list if regexm("`: label (varname)'", "my_regex")

> > list if `: list posof id in ids'

Doing this in a two step process often gets tedious due to the size of the 
data-set and memory limitations. Being able to operate on value labels directly 
as though they were the value of the variable would be particularly helpful.

Also, list was an example. I am rarely interested in actually listing data. 
I've got a class of problems that I am trying to solve and being able to 
dynamically invoke extended functions in the manner described would be helpful. 
If it is not possible, so be it. But I wanted to make sure my question was 
clear first. I thought I had seen someone doing something very close to this at 
some point but cannot find it again.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index