Date: Tue, 10 Mar 2009 07:27:31 -0400
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: need help on my own macro
In-Reply-To: <200903100454.n29K3n8q013083@mailgw.cc.uga.edu>
Content-Type: text/plain; charset="US-ASCII"
Terry
As I count your dos and ends, I think that the statement
%do %while ( &selected_var_num <= &x_var_num );
is not ended but it's way too early in the morning for me to be sure of
where you want it to go.
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
Terry He
<he.terry@GMAIL.C
OM> To
Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU
Discussion" cc
<SAS-L@LISTSERV.U
GA.EDU> Subject
need help on my own macro
03/10/2009 12:54
AM
Please respond to
Terry He
<he.terry@GMAIL.C
OM>
The log file told me that I missed an %end. I don't know where I missed it.
Here is the code:
options symbolgen mprint;
libname src "C:\Project";
libname tgt "C:\Project\the";
******* macro vars need to specify ****;
%let x_vars =
mic_seg_tenure_ind
mic_seg_i360_ind
mic_seg_eq_ind
cart_node
;
%let tgt_var =
tgt_ind
;
%let src_Data =
tgt.gl_no_one_1112_mst8_micro_seg
;
***end of macro vars need to specify ***;
%macro feedforward;
%let selected_var_num = 1;
%let selected_vars = ;
%let selected_var_values = ;
%global k i kk ;
%global x_var_num slct_var_num;
%let k = 1;
%do %while (%scan(&x_vars,&k) ne %str() );
%let k = %eval(&k + 1);
%end;
%let x_var_num = %eval(&k - 1);
%do %while ( &selected_var_num <= &x_var_num );
%do i = 1 %to &x_var_num;
%let var_name = %scan( &x_vars, &i);
%if %length(&selected_vars)>0 %then %do;
%let k = 1;
%do %while ( %scan(&selected_vars,&k) ne %str() );
%let k = %eval(&k + 1);
%end;
%let slct_var_num = %eval(&k - 1);
%end;
%else %do;
%let slct_var_num = 0;
%end;
%do k=1 %to &slct_var_num;
%let exist_var_&k = %scan(&selected_vars,&k);
%let exist_value_&k = %scan(&selected_var_values,&k);
%end;
%if %index(&selected_vars,&var_name)<=0 %then %do;
proc summary data = &src_Data(where=(%if &i>1 %then %do;
%do k=1 %to &slct_var_num;
trim(&&exist_var_&k||'')
ne trim("&&exist_value_&k")
%do kk= 1 %to %eval
(&slct_var_num-1)
and
%end;
%end;
%end;
)) nway missing;
class &var_name;
var &tgt_var;
output out = step_sum_&i mean=;
run;
%end;
%put i will put something;
%put &i &var_name;
data step_sum_&i.;
set step_sum_&i.(drop = _type_ _freq_);
length var_name class_var $32;
var_name = "&var_name";
class_var = trim(&var_name!!'');
drop &var_name;
run;
proc print data = step_sum_&i;run;
%end;
data step_all_set;
set
%do k = 1 %to &x_var_num;
%if %index(&selected_vars,&var_name)<=0 %then %do;
step_sum_&k
%end;
%end;
;
run;
proc sort data = step_all_set; by descending &tgt_var; run;
data _null_;
set step_all_set(obs=1);
call symput("selected_var",var_name);
call symput("rate",&tgt_var);
call symput("var_value",class_var);
run;
%let selected_vars = &selected_vars &selected_var ;
%let selected_var_values =&selected_var_values &var_value ;
/*%let selected_rate&selected_var_num = &rate;*/
%let selected_var_num = %eval(&selected_var_num+1);
%end;
%mend feedforward;
%feedforward;
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.