From: francogrex on 25 Jul 2010 06:42 Hi, I retrieved this Q&A from stack-overflow and they discuss the ability of Macros in certain programming languages to do "meta- programming". In my understanding the Macro as it is in SAS does not do this, but is equivalent to so-called functions in other languages. As you can see from the extract below very few programming languages have the ability to meta-program and even less by using the so-called Macros. Am I right then that the definition of a Macro in SAS is different? ========================================== Extract Q&A: Question: C++ is probably the most popular language for static metaprogramming and Java doesn't support it.Are there any other languages besides C++ that support generative programming (programs that create programs)? Which ones are the best (for learning, for efficiency, for maintenance, for embedded systems, whatever)? Reply: The alternative to template style meta-programming is Macro-style that you see in various Lisp implementations. I would suggest downloading Paul Graham's On Lisp and also taking a look at Clojure if you're interested in a Lisp with macros that runs on the JVM. Macros in Lisp are much more powerful than C/C++ style and constitute a language in their own right -- they are meant for meta-programming.
From: Arthur Tabachneck on 25 Jul 2010 09:56 Since one has the ability to use call execute, dm commands and include files in SAS, the ability to accomplish at least some level of meta- programming appears to be rather clear and not just limited to SAS macros. Art ------------- On Jul 25, 6:42 am, francogrex <fra...(a)grex-removethis.com> wrote: > Hi, I retrieved this Q&A from stack-overflow and they discuss the > ability of Macros in certain programming languages to do "meta- > programming". In my understanding the Macro as it is in SAS does not do > this, but is equivalent to so-called functions in other languages. As > you can see from the extract below very few programming languages have > the ability to meta-program and even less by using the so-called Macros. > Am I right then that the definition of a Macro in SAS is different? > ========================================== > Extract Q&A: > Question: C++ is probably the most popular language for static > metaprogramming and Java doesn't support it.Are there any other > languages besides C++ that support generative programming (programs that > create programs)? Which ones are the best (for learning, for efficiency, > for maintenance, for embedded systems, whatever)? > > Reply: The alternative to template style meta-programming is Macro-style > that you see in various Lisp implementations. I would suggest > downloading Paul Graham's On Lisp and also taking a look at Clojure if > you're interested in a Lisp with macros that runs on the JVM. Macros in > Lisp are much more powerful than C/C++ style and constitute a language > in their own right -- they are meant for meta-programming.
From: francogrex on 25 Jul 2010 15:39 I'm sorry but I don't quite understand. Can you use macros to introduce new syntax into the language? Can you show me if this can be done: /* the DO WHILE loop */ data _null_; i = 1; DO WHILE (i<10); put i=; i=i+1; END; run; /* your implementation of the WHILST loop */ data _null_; i = 1; WHILST (i<10); put i=; i=i+1; END; run; /* or even introduce something like this? */ data _null_; x = 1; UNLESS (x > 5); Put x=; run; Arthur Tabachneck wrote: >Since one has the ability to use call execute, dm commands and include >files in SAS, the ability to accomplish at least some level of meta- >programming appears to be rather clear and not just limited to SAS >macros. > >Art >------------- >On Jul 25, 6:42�am, francogrex <fra...(a)grex-removethis.com> wrote: >> Hi, I retrieved this Q&A from stack-overflow and they discuss the >> ability of Macros in certain programming languages to do "meta- >> programming". In my understanding the Macro as it is in SAS does not do >> this, but is equivalent to so-called functions in other languages. As >> you can see from the extract below very few programming languages have >> the ability to meta-program and even less by using the so-called Macros. >> Am I right then that the definition of a Macro in SAS is different? >> ========================================== >> Extract Q&A: >> Question: C++ is probably the most popular language for static >> metaprogramming and Java doesn't support it.Are there any other >> languages besides C++ that support generative programming (programs that >> create programs)? Which ones are the best (for learning, for efficiency, >> for maintenance, for embedded systems, whatever)? >> >> Reply: The alternative to template style meta-programming is Macro-style >> that you see in various Lisp implementations. I would suggest >> downloading Paul Graham's On Lisp and also taking a look at Clojure if >> you're interested in a Lisp with macros that runs on the JVM. Macros in >> Lisp are much more powerful than C/C++ style and constitute a language >> in their own right -- they are meant for meta-programming. >
From: Arthur Tabachneck on 25 Jul 2010 18:26 francogrex, First, as you can see below, another SAS-L member responded to your original post over on the listserv version of sas-l. Second, yes, you can definitely do the things you described and can even use proc fcmp to simply create functions that make it quite easy. Ian is definitely more expert in SAS macros than I am, thus I'll leave it to him to show you examples. Art -------------- On Jul 25, 3:39 pm, francogrex <fra...(a)grex-removethis.com> wrote: > I'm sorry but I don't quite understand. Can you use macros to introduce > new syntax into the language? Can you show me if this can be done: > /* the DO WHILE loop */ > data _null_; > i = 1; > DO WHILE (i<10); > put i=; > i=i+1; > END; > run; > > /* your implementation of the WHILST loop */ > data _null_; > i = 1; > WHILST (i<10); > put i=; > i=i+1; > END; > run; > > /* or even introduce something like this? */ > > data _null_; > x = 1; > UNLESS (x > 5); > Put x=; > run; > > > > Arthur Tabachneck wrote: > >Since one has the ability to use call execute, dm commands and include > >files in SAS, the ability to accomplish at least some level of meta- > >programming appears to be rather clear and not just limited to SAS > >macros. > > >Art > >------------- > >On Jul 25, 6:42 am, francogrex <fra...(a)grex-removethis.com> wrote: > >> Hi, I retrieved this Q&A from stack-overflow and they discuss the > >> ability of Macros in certain programming languages to do "meta- > >> programming". In my understanding the Macro as it is in SAS does not do > >> this, but is equivalent to so-called functions in other languages. As > >> you can see from the extract below very few programming languages have > >> the ability to meta-program and even less by using the so-called Macros. > >> Am I right then that the definition of a Macro in SAS is different? > >> ========================================== > >> Extract Q&A: > >> Question: C++ is probably the most popular language for static > >> metaprogramming and Java doesn't support it.Are there any other > >> languages besides C++ that support generative programming (programs that > >> create programs)? Which ones are the best (for learning, for efficiency, > >> for maintenance, for embedded systems, whatever)? > > >> Reply: The alternative to template style meta-programming is Macro-style > >> that you see in various Lisp implementations. I would suggest > >> downloading Paul Graham's On Lisp and also taking a look at Clojure if > >> you're interested in a Lisp with macros that runs on the JVM. Macros in > >> Lisp are much more powerful than C/C++ style and constitute a language > >> in their own right -- they are meant for meta-programming.- Hide quoted text - > > - Show quoted text - On Sun, 25 Jul 2010 15:32:59 -0400, Ian Whitlock <iw1sas(a)GMAIL.COM> wrote: >On Sun, Jul 25, 2010 at 3:25 PM, Ian Whitlock <iw1sas(a)gmail.com> wrote: >> francogrex, >> >> As Wikipedia defines metaprogramming >> <http://en.wikipedia.org/wiki/Metaprogramming>, >> >> Metaprogramming is the writing of computer programs that write or >> manipulate other programs (or themselves) as their data, or that >> do part of the work at compile time that would otherwise be done >> at runtime. In many cases, this allows programmers to get more >> done in the same amount of time as they would take to write all >> the code manually, or it gives programs greater flexibility to >> efficiently handle new situations without recompilation. >> >> In this sense, I would define a programming language in a circular >> manner as one that can take in data and output programs. So any >> programming language including SAS can do metaprogramming. >> >> However, of particular interest is languages which can manipulate >> their own programs. Again SAS (without macro) meets this condition >> because a DATA step can read data and write code that is to be >> executed with %INCLUDE in the same program. It is the fact that SAS >> compiles and executes in steps, plus %INLUDE that gives SAS this >> reflexive ability. >> >> SAS macro while another language is closely integrated with SAS and >> one usually thinks of SAS macros as part of a SAS program. (I don't >> really see how one can separate the two languages from the point of >> view as a complete program, although it is very helpful to think of >> two languages as you write the code for this one program.) The role >> of SAS macro is to make metaprogramming in SAS much easier. In >> short SAS macro supports this style of programming while SAS alone >> provides the ability for the programmer to support this style of >> programming. Adding macro really supports this style. >> >> In languages like LISP and Ruby, it is the language itself that >> provides the support for the ability to have the program manipulate >> itself. >> >> Is the difference significant? I think the answer is largely in the >> eye of the beholder. I would say that thinking in this style of >> programming is far more significant than whether you think of the >> language as a combination of parts (SAS compiler/parser, macro >> facility, and executer) or one black box that supports the writing >> of your code. >> >> On the other hand, some might think the SAS institute could provider >> better support for metaprogramming than already provided by SAS >> macro. >> >> Art, if you have the address, please forward to francogrex. >> >> Ian Whitlock >> ============== >> >> >> Date: Sun, 25 Jul 2010 06:56:13 -0700 >> From: Arthur Tabachneck <art297(a)NETSCAPE.NET> >> Subject: Re: SAS macros >> >> Since one has the ability to use call execute, dm commands and include >> files in SAS, the ability to accomplish at least some level of meta- >> programming appears to be rather clear and not just limited to SAS >> macros. >> >> >> Art >> ------------- >> On Jul 25, 6:42 am, francogrex <fra...(a)grex-removethis.com> wrote: >>> Hi, I retrieved this Q&A from stack-overflow and they discuss the >>> ability of Macros in certain programming languages to do "meta- >>> programming". In my understanding the Macro as it is in SAS does not do >>> this, but is equivalent to so-called functions in other languages. As >>> you can see from the extract below very few programming languages have >>> the ability to meta-program and even less by using the so-called Macros.. >>> Am I right then that the definition of a Macro in SAS is different? >>> ========================================== >>> Extract Q&A: >>> Question: C++ is probably the most popular language for static >>> metaprogramming and Java doesn't support it.Are there any other >>> languages besides C++ that support generative programming (programs that >>> create programs)? Which ones are the best (for learning, for efficiency, >>> for maintenance, for embedded systems, whatever)? >>> >>> Reply: The alternative to template style meta-programming is Macro-style >>> that you see in various Lisp implementations. I would suggest >>> downloading Paul Graham's On Lisp and also taking a look at Clojure if >>> you're interested in a Lisp with macros that runs on the JVM. Macros in >>> Lisp are much more powerful than C/C++ style and constitute a language >>> in their own right -- they are meant for meta-programming. >-- >Ian Whitlock
From: Francogrex on 26 Jul 2010 05:38 On Jul 26, 12:26 am, Arthur Tabachneck <art...(a)netscape.net> wrote: > francogrex, > > First, as you can see below, another SAS-L member responded to your > original post over on the listserv version of sas-l. > > Second, yes, you can definitely do the things you described and can > even use proc fcmp to simply create functions that make it quite easy. > > Ian is definitely more expert in SAS macros than I am, thus I'll leave > it to him to show you examples. Thanks Art, your response and Ian's were informative. Actully while digging and trying the first example I gave, can be done like this: %let WHILST=%STR(DO WHILE); data _null_; i=0; &WHILST (i < 10); put i=; i=i+1; END; RUN; It was a rather simple example. What I wanted to know (and it's just out of curiosity for the time being) whether the language of SAS through the use of Macros can be extensible and modifiable and to what extent. For example would there be a problem to have this form below run well in SAS: data _null_; {For i -> 1:10 print i} RUN; and has anyone done this (added a syntax layer to SAS). I'll try to read a little bit more on SAS macros and if anyone has more info to share here would be welcome of course.
|
Next
|
Last
Pages: 1 2 Prev: Merge two table in single report Next: Character date to date format in PROC SQL |