[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"David Moore" <davem@hartman-group.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: In defense of Stata, was RE: syntax question |

Date |
Tue, 19 Nov 2002 13:55:47 -0800 |

Although I complain about the lack of a facility for user defined functions, there is one area in which Stata's macro language surpasses SAS's. Due to the way SAS implements macros, it is very cumbersome for a SAS program (the rough equivalent of a Stata "do" file) to communicate with macros. In Stata, you can write statements, such as "local num_obs = _N", to treat the value of _N as text in subsequent macro program code. For example, I can use the macro variable just created in lines, such as "gen var`num_obs' = _n." You can't easily do this in SAS. In effect, Stata makes no distinction at run-time between program code in an "ado" and code in a "do" file that calls the "ado" program, whereas SAS translates all user written procedures and functions into a standard SAS program prior to run-time. Most important, Stata has built-in support for programmers interested in extending it with procedures that resemble OEM commands. The error checking for commands that follow standard syntax is a significant time saver for those of us who want to maintain the look and feel of Stata when writing our own procedures. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu]On Behalf Of Nick Cox Sent: Tuesday, November 19, 2002 12:50 PM To: statalist@hsphsun2.harvard.edu Subject: st: RE: RE: RE: RE: RE: syntax question David Moore > There's at least one thing you can do with the SAS macro programming > language that I have found useful. You can create > functions. I know egen > allows some limited capabilities with respect to new > variable generation, > but functions are more general. For example, they can be > used to calculate > or return values in many different programming contexts, > not just to create > variables. True. That is, suppose you wanted to write a Stata function to calculate logits. You could write a -egen- function to create new variables, or you could write -logitf- such that you could go logitf 0.5 and it could print 0, and leave behind r(logit) so that you could go logitf <argument> ... = r(logit) So you can't define a function allowing you then to do things like . di logitf(0.5) in just one line. Nick n.j.cox@durham.ac.uk * * 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/ * * 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/

**References**:**st: RE: RE: RE: RE: RE: syntax question***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: RE: RE: RE: RE: RE: syntax question** - Next by Date:
**st: RE: -xtivreg, fe- and -cluster- option** - Previous by thread:
**st: RE: RE: RE: RE: RE: syntax question** - Next by thread:
**st: error with outreg (2nd try)** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |