Date: Thu, 15 Jan 2004 16:55:58 -0500
Reply-To: Don Stanley <don_stanley@PARADISE.NET.NZ>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Don Stanley <don_stanley@PARADISE.NET.NZ>
Subject: Re: How to make them into macro vars?
I think Andrea is saying that those 5-9 variables must exist in any created
dataset, according to the code she has created. The PDV is not of concern,
as only one obs is ever in their at a time. I would simply drop the 5
fields and then no issues relating to those 5-9 fields impact on dataset
size exist.
As regards the other issue, which is how to easily modify the code to cope
with more avg variables, I would remove the current macro code, and replace
with this (I'm assuming that the structure of the IF statements applies
throughout)
filename scrinput "c:\two.txt";
filename avgs "c:\one.txt";
%macro model(number=);
if _n_=1 then do;
infile avgs end=eof ;
retain avg1 - avg&number 0 ;
input avg1 - avg&number ;
drop avg: ; /* removes the avg variables from any output dataset */
end ;
infile scrinput;
input x ;
%do i=1 %to %eval(&number - 1 );
if x < %eval(&i*2) then y = avg&i * x ;
else
%end ;
y= avg&number * x;
%mend;
options mprint ; /* just to see the generated code */
data temp;
%model(number=5)
run;
There are many ways to do this using arrays, multiple datasteps and so on,
this is near the original code (so I assume it will assist in understanding
it). All Andrea need do if she has say 9 avg variables is change the %model
(number=5) to %model(number=9) etc.
Cheers
Don