BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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)
4 REPLIES 4
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
SAS_user
Calcite | Level 5
> 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.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
SAS_user
Calcite | Level 5
I don't see where &y is increasing.
And besides do not use &attrib_item ne

Instead use "&attrib_item" ne ""

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1669 views
  • 0 likes
  • 3 in conversation