home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!spool.mu.edu!darwin.sura.net!paladin.american.edu!auvm!PHPDLS1.EM.CDC.GOV!RJF2
- Encoding: 71 TEXT
- X-Mailer: Microsoft Mail V3.0
- Message-ID: <2B4BBB6E@router.em.cdc.gov>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 7 Jan 1993 09:13:00 EST
- Reply-To: rjf2@PHPDLS1.EM.CDC.GOV
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: rjf2@PHPDLS1.EM.CDC.GOV
- Subject: user-defined macro functions?
- Comments: To: SAS-L@uga.cc.uga.edu
- Lines: 60
-
- content : Response
- summary : user-defined function written in macro
- rlse/platform: V6.07 / MVS
- Ron Fehd : SMTP:BitNet: <rjf2@phpdls1.em.cdc.gov>
- Centers for Disease Control
- 1600 Clifton Rd MS:G25 FAX : 404/639-1778
- Atlanta, GA 30333 USA phone: 404/639-1707
- ????????????????????????????????????????????????????????????????????
- From: John Mark Williams <jmw@TASMAN.CC.UTAS.EDU.AU>
- Subject: user-defined macro functions?
- Hi all,
- Is is possible to write a user-defined function in SAS? Something that would
- operate like:
- %let x = %amacro;
- where amacro will return a value. Alternatively what about
- %amacro(x)
- where the value of x is altered within the macro and is available outside it.
- Many thanks,
- --
- John M Williams,
- School of Health Sciences, University of Tasmania
- J.M.Williams@med.utas.edu.au
- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
- ah, yes, string processing, I love it!
-
- here is a macro for the xor operator, which I wrote for &SYSVER le 5.18;
- note that V6 has the bxor operator (bit-wise xor) which works differently
- than this macro.
-
- %MACRO XOR(COND1,COND2);/*evaluation yields boolean value in (0,1)*/
-
- ( ( &COND1 and not (&COND2)
- or (not &COND1 and (&COND2) ) %MEND;
-
- /*NB: Note Well: no semicolons in this macro!
- caveat: neither COND1 nor COND2 may contain an equals sign: '='
- use operator 'eq' and it works fine*/
-
- usage in data step:
-
- DATA;
- set <something>;
- if %XOR(A,B) then <do something1>;
- if %XOR(C eq D,D gt E) then <do something2>;
- if %XOR(first.ID,last.ID);
- /*try this with F & G in (0,1,2,3)*/
- Var_xor = %XOR(F,G);
- Var_bxor = bxor(F,G);
-
- a macro (procedure or subroutine) to pad a char var with dots
- %MACRO SPAC2DOT(VAR);
- &VAR = translate(&VAR.,'.',' '); %MEND;
-
- usage in data step:
-
- DATA;
- set <something>;
- %SPAC2DOT(Char6);
-
- happy crunching!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!
-