DATA Step, Macro, Functions and more

why wouldn't it work out

Reply
N/A
Posts: 0

why wouldn't it work out

When I am trying to run the following code, it can not stop at all. Could some one figure it out for me? Thanks


libname project 'G:\Courseinfo\fall2009\CS699\presentation';
options validvarname=any mprint mlogic mautosource symbolgen;

%macro test(original_data);
%let attrib_list_T0=D2_class DFA_class HNR_class Jitter_DDP_class MDVP_APQ_class MDVP_Fhi_class MDVP_Flo_class MDVP_Fo_class MDVP_Jitter_class MDVP_PPQ_class MDVP_RAP_class
MDVP_Shimmer_class NHR_class PPE_class RPDE_class Shimmer_APQ3_class Shimmer_APQ5_class Shimmer_DDA_class spread1_class spread2_class;

%let y=1;
%let attrib_item=D2_class;
proc sql noprint;
%do %while (&attrib_item ne ); *****acquiring value counts and value list of each attribute from table T0******;

select count(distinct trim(&attrib_item)) into :T0_&attrib_item._value_count
from project.&original_data;
select distinct trim(&attrib_item) into :T0_&attrib_item._values separated by '*'
from project.&original_data;

%let attrib_item=%scan(&attrib_list_T0, %eval(&y+1), %str( ));

%end;
quit;
%mend;

%test(merged_pd_data)
Super Contributor
Super Contributor
Posts: 3,174

Re: why wouldn't it work out

Posted in reply to deleted_user
You cannot combine macro language (specifically your use of macro variables) with the PROC SQL code that is supposed to generate the macro variable values.

If you were to add:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MLOGIC;

you would see the looping condition.

You need to separately generate the macro variable(s) containing your criteria upfront and then use the %DO / %END to loop through the pre-defined variable list.

Search the SAS support http://support.sas.com/ website for using macro language to generate code.


Scott Barry
SBBWorks, Inc.
Contributor
Posts: 48

Re: why wouldn't it work out

> You cannot combine macro language (specifically your
> use of macro variables) with the PROC SQL code that
> is supposed to generate the macro variable values.


Why not? Everything seems to be ok.
Macro generates code. Code generates macroVars.
Super Contributor
Super Contributor
Posts: 3,174

Re: why wouldn't it work out

My mistake - you are correct and the code should work, but the problem, as mentioned in another forum reply is that your &Y variable never gets incremented in a %LET assignment statement.

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 48

Re: why wouldn't it work out

Posted in reply to deleted_user
I don't see where &y is increasing.
And besides do not use &attrib_item ne

Instead use "&attrib_item" ne ""
Ask a Question
Discussion stats
  • 4 replies
  • 163 views
  • 0 likes
  • 3 in conversation