LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2006, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Aug 2006 09:45:53 -0500
Reply-To:     SAS_learner <proccontents@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS_learner <proccontents@GMAIL.COM>
Subject:      Re: Tip of the day: SAS Abbreviations (was Re: macros)
Comments: To: Arthur Tabachneck <art297@netscape.net>
In-Reply-To:  <200608230802.k7N5NWjX014686@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hello Aurther, I did follow this topic little bit , I think every body agreed upon using %, but there is something I do not know is how much of difference it between writing a regular piece of code and put it inside a %macro and %mend and compile code , my knowledge is very little on macro's .

What I am thinking is something like this , If I write a code like this

%macro test(ds= ); data &ds; set &ds; if xxxx = '123' then xxxx= '234' ; else xxxx = 'no number' ; run; %mend;

to

%macro test(ds= ); data &ds; set &ds; %if xxxx = '123' %then xxxx= '234' ; %else xxxx = 'no number' ; run; %mend;

I am sure this has been discussed earlier under a different topic which I do not know

On 8/23/06, Arthur Tabachneck <art297@netscape.net> wrote: > > Visouni, > > Not meaning to disagree with what everyone else has said, but there really > is a way to we avoid writing % so many times for a macro if condition. > And, more, the method can also be used to help one remember all of the > intricacies of various SAS procs so that you always aren't forced to pull > up the SAS documentaion, as well as to store stylized code (like a > specialized comment block with lots of asterisks, etc.). > > 1. From the SAS menu click on Tools->Add Abbreviation > > 2. Then type in the desired abbreviation: for example, mif > to represent macro if > > 3. Then in the box where it says "Text to insert for abbreviation" type in > the characters which you are trying to avoid entering. For example: > > %if x eq y %then %do; > > %end; > %else %then %do; > > %end; > > > 4. Then click on "OK" > > After that, whenever you type mif a box will appear showing that it is an > abbreviation. And, if you then enter the tab key while the box is > showing, the entire text related to that abbreviation will appear in your > program. > > HTH, > Art > > P.S. Too bad that Chris chose the dark side to describe Macros, I tend to > associate them more with "the force." Besides, Darth Macro (In)Vader has > already claimed the dark side for other nice, powerfull SAS features. > ---------------- > ChrisW75 <9Squirrels@GMAIL.COM> wrote: > Once you've got the hang of base SAS and have really got into the nuts > and bolts and people start asking you to do complex tasks, you'll start > to open up to the wonders of the SAS Macro language. > It's pretty damned simple, and oh so very powerful. > > Kind of like the Dark Side. > > Yes, strike out with your anger, feel how powerful the darkside is. > > But seriously, start with little baby steps and build up, and you'll > realise how great it is, the % signs just help you to distinguish > between macro code and regular SAS code. I just wrote a program using > Base SAS and Macro. I wrote it first in Base, and it took 1 input > file, and split out one group of records and wrote them out into 2 > files. I then pulled out the parameters, wrote some code to generate > macro variables, put a loop around the output code, and within half an > hour I had a program which wrote out 94 separate Excel spreadsheets > from 1 input file. > > The whole program is less than 300 lines, and that's nicely formatted > code with blank lines and comments and stuff. Try doing that in Base > SAS and you'd be there all week typing it out, and then you'd end up > with a program that'll only work on that specific data, rather than a > dynamic program which takes it's cues from the data it reads in. > > As Yoda said "Learn to love the % sign you will when a great programmer > you become. Shorten your programs it can, new avenues it will open". > > > visouni@gmail.com wrote: > > Is there a way to avoid writing % more times..that is decrease the > > number of times of writing % while writing macros..please help.. > > > > %macro > > %if condition %then > > .. > > %else > > .. > > %mend > > > > So my question is can we avooid writing % somany times for the if > > condition?? >


Back to: Top of message | Previous page | Main SAS-L page