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 ""

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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