home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / bit / listserv / sasl / 3733 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  1.9 KB

  1. Path: sparky!uunet!stanford.edu!lll-winken!elroy.jpl.nasa.gov!usc!wupost!darwin.sura.net!paladin.american.edu!auvm!NIEHS.BITNET!WHITMIR1
  2. From: WHITMIR1@NIEHS.BITNET
  3. Newsgroups: bit.listserv.sas-l
  4. Subject: Including macros into SAS program
  5. Message-ID: <01GNKNSBOEGG8ZE3T6@NIEHS.BITNET>
  6. Date: 14 Aug 92 18:38:00 GMT
  7. Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. Reply-To: WHITMIR1@NIEHS.BITNET
  9. Lines: 49
  10. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  11. X-Envelope-to: SAS-L@VTVM2.BITNET
  12. X-VMS-To: IN%"SAS-L@VTVM2.BITNET"
  13. X-VMS-Cc: WHITMIR1
  14.  
  15. Hello ,
  16.  
  17. I have large nested IF THEN ELSE in my program.  I wanted to know if there is a
  18. way to write section of the code in macro to make the program more efficient.
  19. I know a little about macro but not enough to write one on my own!
  20. I looked at the section "Including macros into sas program" of SAS guide to
  21. macro processing.  The problem is I don't know how to write a macro.
  22. Could anybody help me on that. I included part of the sample program below.
  23. Thanks in advance.
  24.  
  25. DATA ALL;
  26.  MERGE ONE(IN=IN1) TWO(IN=IN2);
  27.   BY ID;
  28. IF IN1 AND IN2;
  29.  
  30. TSTREFMO = .;   TSTREFYR = .;
  31. IF (RC33 ^= 997 AND RC33 ^= 998) AND (RC46 ^= 997 AND RC46 ^= 998) THEN
  32.  DO;
  33.   IF RC33 = 1 THEN
  34.    DO;
  35.     TSTREFMO = TESTMO;
  36.     TSTREFYR = TESTYR;
  37.    END;
  38.   IF RC33 = 2  THEN
  39.    DO;
  40.     IF TESTMO IN (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) THEN
  41.      DO;
  42.       TSTREFMO = TESTMO - 1;
  43.       TSTREFYR = TESTYR;
  44.      END;
  45.     ELSE IF TESTMO = 1 THEN
  46.      DO;
  47.       TSTREFMO = 12;
  48.       TSTREFYR = TESTYR - 1;
  49.      END;
  50.    END;
  51. END;
  52. IF (TSTRF_DT NE . AND RC33_DT NE .) THEN
  53.  DO;
  54.   IF (RC33_DT NE TSTRF_DT) THEN
  55.    DO;
  56.     VAR1 = 'RC33 = ' || PUT(RC33,Z3.);
  57.     VAR2 = 'RC33_DT = ' || PUT(RC33MO,Z2.) || PUT(RC33YR,Z2.);
  58.     VAR3 = 'TSTRF_DT = ' || PUT(TSTREFMO,Z2.) || PUT(TSTREFYR,Z2.);
  59.     VAR4 = 'RC32_DT = ' || PUT(RC32MO,Z2.) || PUT(RC32YR,Z2.);
  60.     VAR5 = 'RC32A_DT = ' || PUT(RC32AMO,Z2.) || PUT(RC32AYR,Z2.);
  61.     OUTPUT;
  62.    END;
  63.  END;
  64.