Hi,
Really stumped by this one (so probably something really obvious that I'm missing).
I'm trying to develop a macro with nested DO loops to cycle through all possible combinations of two sets of character variables and 3 sets of numeric variables. The full code is quite lengthy but I'm hoping what I show here will contain the relevant parts.
To cycle through my list of character variables I have coded the following (the first variable has two categories, the second has four): -
%let h_lst = HA NH;
%let start=%sysfunc(indexc(%sysfunc(compress(&h_lst)),&beg));
%let finish=%sysfunc(indexc(%sysfunc(compress(&h_lst)),&end));
%let g_lst = AW CHASE FLAT HURDLE;
%let start1=%sysfunc(indexc(%sysfunc(compress(&g_lst)),&beg1));
%let finish1=%sysfunc(indexc(%sysfunc(compress(&g_lst)),&end1));
%do h = &start %to &finish;
%do g = &start1 %to &finish1;
%do i=9 %to 9;
%do j=9 %to 9;
%do k=28 %to 30;
I call the macro using keyword parameters: -
%macro super_macro
(beg=HA,
end=NH,
beg1=AW,
end1=HURDLE);
When I run the macro, it cycles through all my required variables apart from those in h_lst. The log tells me that although SAS is identifying the list has a BEG of HA and an END of NH, that part of the loop has a start and end value of 1, where I would expect the start value to be 1 and the end value to be 2. The exact same code method used for g_lst works fine and has a start value of 1 and end value of 4. The log for this section is below: -
MLOGIC(SUPER_MACRO): %LET (variable name is H_LST)
MLOGIC(SUPER_MACRO): %LET (variable name is START)
SYMBOLGEN: Macro variable H_LST resolves to HA NH
SYMBOLGEN: Macro variable BEG resolves to HA
MLOGIC(SUPER_MACRO): %LET (variable name is FINISH)
SYMBOLGEN: Macro variable H_LST resolves to HA NH
SYMBOLGEN: Macro variable END resolves to NH
MLOGIC(SUPER_MACRO): %LET (variable name is G_LST)
MLOGIC(SUPER_MACRO): %LET (variable name is START1)
SYMBOLGEN: Macro variable G_LST resolves to AW CHASE FLAT HURDLE
SYMBOLGEN: Macro variable BEG1 resolves to AW
MLOGIC(SUPER_MACRO): %LET (variable name is FINISH1)
SYMBOLGEN: Macro variable G_LST resolves to AW CHASE FLAT HURDLE
SYMBOLGEN: Macro variable END1 resolves to HURDLE
SYMBOLGEN: Macro variable START resolves to 1
SYMBOLGEN: Macro variable FINISH resolves to 1
MLOGIC(SUPER_MACRO): %DO loop beginning; index variable H; start value is 1; stop value is 1; by value is 1.
SYMBOLGEN: Macro variable START1 resolves to 1
SYMBOLGEN: Macro variable FINISH1 resolves to 4
MLOGIC(SUPER_MACRO): %DO loop beginning; index variable G; start value is 1; stop value is 4; by value is 1.
As I say, it's probably something really obvious that I'm missing but I just can't figure it out so if anyone could point me in the right direction, I'd be hugely appreciative.
Many thanks,
Rob