home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!LOBBY.TI.COM!RSNYDER
- X-Mailer: ELM [version 2.2 PL16]
- Message-ID: <9207301956.AA08984@ti.com>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 30 Jul 1992 14:56:04 CDT
- Reply-To: "R. Snyder" <rsnyder@LOBBY.TI.COM>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: "R. Snyder" <rsnyder@LOBBY.TI.COM>
- Subject: Re: calculations within a %MACRO
- Comments: To: SCHICK%DMRHRZ11.BITNET@uga.cc.uga.edu
- Comments: cc: sas-l@uga.cc.uga.edu
- In-Reply-To: <9207301428.AA23082@ti.com>; from "Arnold Schick" at Jul 30,
- 92 3:10 pm
- Lines: 88
-
- Arnold Schick writes:
- >
- > Hallo ALL,
- >
- > within a %MACRO I have to calculate one value for a variable, which
- > to find in cases of _N_ = 1,2,3 (see below). Now, I produce test data
- > for this %MACRO and the %MACRO will work only for one sort of data.
- >
- > With the first sort of data creates it not an ANFANG data set and for the
- > second sort is it created. I want to locate the conditions for the
- > unproducing and can't find it (pherhaps too long looked to ...). Yes I
- > know, the missings, but the third (_N_=3) should be given out to ANFANG
- > in both situations.
- >
- > The platform and/or version of SAS is not the cause.
- >
- > Has everyone an idea, why it runs on this different ways? Many Thanks.
- >
- >
- > Arnold Schick University of Marburg/Germany BITNET: SCHICK@DMRHRZ11
- > Internet: Schick@ibm.hrz.uni-marburg.DE
- >
- > Here is the reduced %MACRO:
- >
- >
- > %macro kif3d (data,x,y,z);
- > /* ..... */
- >
- > data _NULL_ ;
- > set &data;
- > &y = fuzz(&y);
- > if _N_ = 1 then call symput('y_1',&y);
- > if _N_ = 2 then call symput('y_2',&y);
- > if _N_ = 3 then do; call symput('y_3',&y); stop; end;
- > run;
- >
- > data anfang(keep= &x dz_start);
- > set &data;
- > &y = fuzz(&y);
- > &z = fuzz(&z);
- > y1 = lag(&y);
- > z1 = lag(&z);
- > if (&y=&y_2) or (&y=&y_3) then do;
- > dz = (&z - z1)/(&y - y1);
- > dz_b = lag(dz);
- > if &y=&y_3 then do;
- > dz_start = 2*dz_b - dz;
- > output anfang;
- > end;
- > end;
- > run;
- >
- > /*....*/
- > %mend kif3d;
- >
- > < invocation code deleted >
- >
- Arnold,
-
- I don't quite know what this macro does but I think I see the problem.
- In your second data step you are referencing Y_2 and y_3 via macro
- expansion. The problem is that the expansion occures before either data
- step executes and so their values are still null.
-
- Try this:
-
- data anfang(keep= &x dz_start);
- set &data;
- &y = fuzz(&y);
- &z = fuzz(&z);
- y1 = lag(&y);
- z1 = lag(&z);
- y_1 = input( symget('y_1'), best. );
- y_2 = input( symget('y_2'), best. );
- y_3 = input( symget('y_3'), best. );
- if (&y=y_2) or (&y=y_3) then do;
- dz = (&z - z1)/(&y - y1);
- dz_b = lag(dz);
- if &y=y_3 then do;
- dz_start = 2*dz_b - dz;
- output anfang;
- end;
- end;
-
- I hope something like this dows the trick for you.
-
- Bob Snyder, Texas Instruments, Sherman, TX
- run;
-