Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Unfortunately -for3- does not replicate the basic, and only functionality of the old -for- I use.

    The basic and only functionality of the old -for- I use is to repeat a series of actions for a given list. The -for3- does not accept the backslash \ to specify that consecutive actions need to be performed on the list:



    Code:
    . sysuse auto, clear
    (1978 Automobile Data)
    
    . for var price mpg headroom: summ X \ sca SX = r(mean)
    
    ->  summ price
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
           price |         74    6165.257    2949.496       3291      15906
    
    ->  sca Sprice = r(mean)
    
    ->  summ mpg
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
             mpg |         74     21.2973    5.785503         12         41
    
    ->  sca Smpg = r(mean)
    
    ->  summ headroom
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
        headroom |         74    2.993243    .8459948        1.5          5
    
    ->  sca Sheadroom = r(mean)
    
    . sca list
     Sheadroom =  2.9932432
          Smpg =  21.297297
        Sprice =  6165.2568
    
    . for3 price mpg headroom, ltype(varlist): summ @ \ sca S@ = r(mean)
    
    -> summ price \ sca Sprice = r(mean)
    \ invalid name
    r(198);
    
    .
    Originally posted by Nick Cox View Post
    My guess is for is gone and never coming back. These versions of the command remain accessible as well as completely documented.


    Code:
    . search ip8, historical entry
    
    Search of official help files, FAQs, Examples, and Stata Journals.
    STB-30 ip8.1 . . . . . . . . . . . . . . . An even more enhanced for command
    (help for3 if installed) . . . . . . . . . . . . . . . . . P. Royston
    3/96 pp.5--6; STB Reprints Vol 5, pp.65--66
    incorporated into improved for command in Stata 5.0
    
    STB-26 ip8 . . . . . . . . . . . . . . . . . . . . . An enhanced for command
    (help for2 if installed) . . . . . . . . . . . . . . . . . P. Royston
    7/95 p.12; STB Reprints Vol 5, p.65
    incorporated into improved for command in Stata 5.0

    Comment


    • #17
      These FAQs explain indirectly why the peculiar flexibility of the old for sowed the seeds of its own demise. People got themselves into extraordinary messes and it wasn't easy to link it to anything else in Stata programming, especially local macros.

      Why do I get puzzling results with the for command and local or global macros?

      Why do some nested for commands produce an error?

      The code for for is still accessible even if the help file has disappeared. Anyone so inclined can try hacking at the code but I predict that it will prove frustrating.

      Comment

      Working...
      X