home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!munnari.oz.au!spool.mu.edu!sol.ctr.columbia.edu!howland.reston.ans.net!paladin.american.edu!auvm!COMPUSERVE.COM!75046.1627
- Message-ID: <930107145304_75046.1627_CHI55-1@CompuServe.COM>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 7 Jan 1993 09:53:04 EST
- Reply-To: Michael Davis <75046.1627@COMPUSERVE.COM>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Michael Davis <75046.1627@COMPUSERVE.COM>
- Subject: Re: user-defined functions
- Comments: To: SAS-L@uga.cc.uga.edu
- Lines: 52
-
- -----------------------------------------------------------------------
- CONTENT: response to question re: user-defined macro functions
- SUMMARY: use FORMAT procedure plus PUT, INPUT functions
- REL/PLTF: all
- E-ADDR: 0002395748@mcimail.com
- P-ADDR: BC&BS OF Conn., 370 Bassett Road, North Haven, CT 06473
- PHONE: (203)-985-7187
- FAX: (203)-985-7030
- -----------------------------------------------------------------------
-
- John Mark Williams <jmw@tasman.cc.utas.edu.au> asked if it was
- possible to write a user-defined function in SAS? Well, John, it
- is and you do not need to use macros. Simply combine the FORMAT
- procedure with either an INPUT or PUT function. For example,
-
- proc format;
- value $JMW
- 'A'= 'YES'
- other= 'NO'
- ;
- run;
- data JMW;
- input @1 test $1.;
- cards;
- A
- B
- ;
- data _null_;
- set JMW;
- x= put(test,$JMW.);
- put x;
- run;
-
- In this example, the PUT function assigns a value to the variable
- x according to the translation table created by the user-defined
- function $JMW. If you run the above program and look at the log,
- you will see that YES was assigned to X when TEST equaled A for the
- first observation and NO was assigned to X when TEST equaled B.
-
- As a strategy, consider using the LIBRARY option so that you can
- reuse formats. Another benefit is that if you change the format,
- all programs that use it are updated.
-
- If you are using Release 6.07 or a later release, you may wish to
- create your format using a data set as input. Earlier releases
- could do this with the use of macros but it was more complicated.
- It is usually quicker to create and maintain complicated formats
- using a data set as input.
-
-
- Distribution:
- >internet: SAS-L@uga.cc.uga.edu
-