Bookmark and Share

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]

RE: st: use of subinstr


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: use of subinstr
Date   Fri, 23 Mar 2012 15:47:25 +0000

Extended functions: 

I would not read too much into the wording here. In practice extended _macro_ functions are whatever are documented as such at -help extended_fcn-. The word "extended" does not have any implications that I can recall in any other context. I guess it's pure accident that they include functions for dealing with longer strings, as that doesn't define them. StataCorp may have a story on the word "extended", but it doesn't define a concept. 

-unab-: 

-unab- is a command. When you see a keyword like this type -search unab- at the command line and references to Stata's documentation and other material will typically appear. 

Third question: 

This would take much more than a few sentences to answer. The basics are very well covered in the later chapters of [U]: you should certainly start there rather than [P]. These manuals are included as .pdf with your version of Stata. Specifically on -foreach- there is a tutorial at  

SJ-2-2  pr0005  . . . . . .  Speaking Stata:  How to face lists with fortitude
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
        Q2/02   SJ 2(2):202--222                                 (no commands)
        demonstrates the usefulness of for, foreach, forvalues, and
        local macros for interactive (non programming) tasks

which is accessible online. SJ means Stata Journal and issues more than 3 years are freely available at the Stata Journal website. 

Nick 
[email protected] 

tashi lama

Thank you guys for your help. I am a beginer in stata programming although my little background in C++ and BASIC programming has helped me a lot to understand and learn Stata programming. I have few questions on stata basics which I hope you guys will throw some light on or at least give me a lead. 

1.    What are extended functions and why do we use it? My initial thought would be to extend the length of the string like you guys did for subinstr.  

2.    when you say 

unab varlist :var*               what is the code doing? As a matter of fact, what is unab? Is varlist a macro here? Why are we using ":" here? Actually what is ":"? 

3. when you say 

ds var*

local varlist `r(varlist)' 

foreach x of local varlist {

 code...

}   

 

instead of 3., could we have said           foreach x of varlist var* {

                                                   code...

                                                   }

   

Please explain me what is the diff between two codes. And when you say   local varlist `r(varlist)', what are you doing? are you defining a macro called varlist and storing it in r(varlist)? If that is the case, I don't understand why is that we have to store?  Pls explain. 


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index