home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / bit / listserv / sasl / 3496 < prev    next >
Encoding:
Text File  |  1992-07-30  |  3.1 KB  |  105 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!LOBBY.TI.COM!RSNYDER
  3. X-Mailer: ELM [version 2.2 PL16]
  4. Message-ID: <9207301956.AA08984@ti.com>
  5. Newsgroups: bit.listserv.sas-l
  6. Date:         Thu, 30 Jul 1992 14:56:04 CDT
  7. Reply-To:     "R. Snyder" <rsnyder@LOBBY.TI.COM>
  8. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  9. From:         "R. Snyder" <rsnyder@LOBBY.TI.COM>
  10. Subject:      Re: calculations within a %MACRO
  11. Comments: To: SCHICK%DMRHRZ11.BITNET@uga.cc.uga.edu
  12. Comments: cc: sas-l@uga.cc.uga.edu
  13. In-Reply-To:  <9207301428.AA23082@ti.com>; from "Arnold Schick" at Jul 30,
  14.               92 3:10 pm
  15. Lines: 88
  16.  
  17. Arnold Schick writes:
  18. >
  19. > Hallo ALL,
  20. >
  21. > within a %MACRO I have to calculate one value for a variable, which
  22. > to find in cases of _N_ = 1,2,3 (see below). Now, I produce test data
  23. > for this %MACRO and the %MACRO will work only for one sort of data.
  24. >
  25. > With the first sort of data creates it not an ANFANG data set and for the
  26. > second sort is it created. I want to locate the conditions for the
  27. > unproducing and can't find it (pherhaps too long looked to ...). Yes I
  28. > know, the missings, but the third (_N_=3) should be given out to ANFANG
  29. > in both situations.
  30. >
  31. > The platform and/or version of SAS is not the cause.
  32. >
  33. > Has everyone an idea, why it runs on this different ways?  Many Thanks.
  34. >
  35. >
  36. > Arnold Schick  University of Marburg/Germany BITNET: SCHICK@DMRHRZ11
  37. >                                      Internet: Schick@ibm.hrz.uni-marburg.DE
  38. >
  39. > Here is the reduced %MACRO:
  40. >
  41. >
  42. > %macro kif3d (data,x,y,z);
  43. >   /* ..... */
  44. >
  45. >   data _NULL_ ;
  46. >     set &data;
  47. >     &y = fuzz(&y);
  48. >     if _N_ = 1 then call symput('y_1',&y);
  49. >     if _N_ = 2 then call symput('y_2',&y);
  50. >     if _N_ = 3 then do; call symput('y_3',&y); stop; end;
  51. >   run;
  52. >
  53. >   data anfang(keep= &x dz_start);
  54. >      set &data;
  55. >      &y = fuzz(&y);
  56. >      &z = fuzz(&z);
  57. >      y1 = lag(&y);
  58. >      z1 = lag(&z);
  59. >      if (&y=&y_2) or (&y=&y_3) then do;
  60. >             dz   = (&z - z1)/(&y - y1);
  61. >             dz_b = lag(dz);
  62. >             if &y=&y_3 then do;
  63. >                dz_start = 2*dz_b - dz;
  64. >                output anfang;
  65. >             end;
  66. >      end;
  67. >   run;
  68. >
  69. >   /*....*/
  70. > %mend kif3d;
  71. >
  72. > < invocation code deleted >
  73. >
  74. Arnold,
  75.  
  76. I don't quite know what this macro does but I think I see the problem.
  77. In your second data step you are referencing Y_2 and y_3 via macro
  78. expansion. The problem is that the expansion occures before either data
  79. step executes and so their values are still null.
  80.  
  81. Try this:
  82.  
  83.  data anfang(keep= &x dz_start);
  84.     set &data;
  85.     &y = fuzz(&y);
  86.     &z = fuzz(&z);
  87.     y1 = lag(&y);
  88.     z1 = lag(&z);
  89.     y_1 = input( symget('y_1'), best. );
  90.     y_2 = input( symget('y_2'), best. );
  91.     y_3 = input( symget('y_3'), best. );
  92.     if (&y=y_2) or (&y=y_3) then do;
  93.            dz   = (&z - z1)/(&y - y1);
  94.            dz_b = lag(dz);
  95.            if &y=y_3 then do;
  96.               dz_start = 2*dz_b - dz;
  97.               output anfang;
  98.            end;
  99.     end;
  100.  
  101. I hope something like this dows the trick for you.
  102.  
  103. Bob Snyder, Texas Instruments, Sherman, TX
  104.  run;
  105.