BookmarkSubscribeRSS Feed
david27
Quartz | Level 8

I have this code:

options symbolgen mprint mlogic;
%let cnt_id_groups=5;
%let cnt_Id_value_groups=8;
%macro dummy;
%do i = 1 %to &cnt_id_groups.;
	%do j=1 %to &cnt_Id_value_groups.;
		%let value_&i._&j=;
	%end;
%end;
%mend dummy;
%dummy;
%PUT VALUE_4_4=&VALUE_4_4;
%PUT VALUE_5_8=&VALUE_5_8;

Why would i not get the value for macro -- value_5_8?
what should i do?

Here is the log:

28         options symbolgen mprint mlogic;
29         %let cnt_id_groups=5;
30         %let cnt_Id_value_groups=8;
31         %macro dummy;
32         %do i = 1 %to &cnt_id_groups.;
33         	%do j=1 %to &cnt_Id_value_groups.;
34         		%let value_&i._&j=;
35         	%end;
36         %end;
37         %mend dummy;
38         %dummy;
MLOGIC(DUMMY):  Beginning execution.
SYMBOLGEN:  Macro variable CNT_ID_GROUPS resolves to 5
MLOGIC(DUMMY):  %DO loop beginning; index variable I; start value is 1; stop value is 5; by value is 1.  
SYMBOLGEN:  Macro variable CNT_ID_VALUE_GROUPS resolves to 8
MLOGIC(DUMMY):  %DO loop beginning; index variable J; start value is 1; stop value is 8; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_1)
MLOGIC(DUMMY):  %DO loop index variable J is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_2)
MLOGIC(DUMMY):  %DO loop index variable J is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 3
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_3)
MLOGIC(DUMMY):  %DO loop index variable J is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 4
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_4)
MLOGIC(DUMMY):  %DO loop index variable J is now 5; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 5
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_5)
MLOGIC(DUMMY):  %DO loop index variable J is now 6; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 6
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_6)
MLOGIC(DUMMY):  %DO loop index variable J is now 7; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 7
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_7)
MLOGIC(DUMMY):  %DO loop index variable J is now 8; loop will iterate again.
3                                                          The SAS System                             09:54 Thursday, March 21, 2024

SYMBOLGEN:  Macro variable I resolves to 1
SYMBOLGEN:  Macro variable J resolves to 8
MLOGIC(DUMMY):  %LET (variable name is VALUE_1_8)
MLOGIC(DUMMY):  %DO loop index variable J is now 9; loop will not iterate again.
MLOGIC(DUMMY):  %DO loop index variable I is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable CNT_ID_VALUE_GROUPS resolves to 8
MLOGIC(DUMMY):  %DO loop beginning; index variable J; start value is 1; stop value is 8; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_1)
MLOGIC(DUMMY):  %DO loop index variable J is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_2)
MLOGIC(DUMMY):  %DO loop index variable J is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 3
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_3)
MLOGIC(DUMMY):  %DO loop index variable J is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 4
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_4)
MLOGIC(DUMMY):  %DO loop index variable J is now 5; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 5
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_5)
MLOGIC(DUMMY):  %DO loop index variable J is now 6; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 6
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_6)
MLOGIC(DUMMY):  %DO loop index variable J is now 7; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 7
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_7)
MLOGIC(DUMMY):  %DO loop index variable J is now 8; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 2
SYMBOLGEN:  Macro variable J resolves to 8
MLOGIC(DUMMY):  %LET (variable name is VALUE_2_8)
MLOGIC(DUMMY):  %DO loop index variable J is now 9; loop will not iterate again.
MLOGIC(DUMMY):  %DO loop index variable I is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable CNT_ID_VALUE_GROUPS resolves to 8
MLOGIC(DUMMY):  %DO loop beginning; index variable J; start value is 1; stop value is 8; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_1)
MLOGIC(DUMMY):  %DO loop index variable J is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_2)
MLOGIC(DUMMY):  %DO loop index variable J is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 3
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_3)
MLOGIC(DUMMY):  %DO loop index variable J is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 4
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_4)
MLOGIC(DUMMY):  %DO loop index variable J is now 5; loop will iterate again.
4                                                          The SAS System                             09:54 Thursday, March 21, 2024

SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 5
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_5)
MLOGIC(DUMMY):  %DO loop index variable J is now 6; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 6
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_6)
MLOGIC(DUMMY):  %DO loop index variable J is now 7; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 7
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_7)
MLOGIC(DUMMY):  %DO loop index variable J is now 8; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 3
SYMBOLGEN:  Macro variable J resolves to 8
MLOGIC(DUMMY):  %LET (variable name is VALUE_3_8)
MLOGIC(DUMMY):  %DO loop index variable J is now 9; loop will not iterate again.
MLOGIC(DUMMY):  %DO loop index variable I is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable CNT_ID_VALUE_GROUPS resolves to 8
MLOGIC(DUMMY):  %DO loop beginning; index variable J; start value is 1; stop value is 8; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_1)
MLOGIC(DUMMY):  %DO loop index variable J is now 2; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_2)
MLOGIC(DUMMY):  %DO loop index variable J is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 3
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_3)
MLOGIC(DUMMY):  %DO loop index variable J is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 4
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_4)
MLOGIC(DUMMY):  %DO loop index variable J is now 5; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 5
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_5)
MLOGIC(DUMMY):  %DO loop index variable J is now 6; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 6
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_6)
MLOGIC(DUMMY):  %DO loop index variable J is now 7; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 7
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_7)
MLOGIC(DUMMY):  %DO loop index variable J is now 8; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 4
SYMBOLGEN:  Macro variable J resolves to 8
MLOGIC(DUMMY):  %LET (variable name is VALUE_4_8)
MLOGIC(DUMMY):  %DO loop index variable J is now 9; loop will not iterate again.
MLOGIC(DUMMY):  %DO loop index variable I is now 5; loop will iterate again.
SYMBOLGEN:  Macro variable CNT_ID_VALUE_GROUPS resolves to 8
MLOGIC(DUMMY):  %DO loop beginning; index variable J; start value is 1; stop value is 8; by value is 1.  
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 1
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_1)
MLOGIC(DUMMY):  %DO loop index variable J is now 2; loop will iterate again.
5                                                          The SAS System                             09:54 Thursday, March 21, 2024

SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 2
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_2)
MLOGIC(DUMMY):  %DO loop index variable J is now 3; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 3
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_3)
MLOGIC(DUMMY):  %DO loop index variable J is now 4; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 4
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_4)
MLOGIC(DUMMY):  %DO loop index variable J is now 5; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 5
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_5)
MLOGIC(DUMMY):  %DO loop index variable J is now 6; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 6
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_6)
MLOGIC(DUMMY):  %DO loop index variable J is now 7; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 7
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_7)
MLOGIC(DUMMY):  %DO loop index variable J is now 8; loop will iterate again.
SYMBOLGEN:  Macro variable I resolves to 5
SYMBOLGEN:  Macro variable J resolves to 8
MLOGIC(DUMMY):  %LET (variable name is VALUE_5_8)
MLOGIC(DUMMY):  %DO loop index variable J is now 9; loop will not iterate again.
MLOGIC(DUMMY):  %DO loop index variable I is now 6; loop will not iterate again.
MLOGIC(DUMMY):  Ending execution.
39         %PUT VALUE_4_4=&VALUE_4_4;
SYMBOLGEN:  Macro variable VALUE_4_4 resolves to 
VALUE_4_4=
40         %PUT VALUE_5_8=&VALUE_5_8;
WARNING: Apparent symbolic reference VALUE_5_8 not resolved.
VALUE_5_8=&VALUE_5_8
3 REPLIES 3
PaigeMiller
Diamond | Level 26

Why would i not  the value for macro -- value_5_8?

 

This macro variable was created inside the macro and is not defined outside the macro. You could include a %GLOBAL command inside the macro.

 

 %global value_5_8;

 

 

By the way, this looks like a overly complicated use of the macro language, and I bet there a much simpler ways to go. Please describe why you doing this, in words, at a high level so that your boss's boss would understand the project, and please tell us in words what would you do with these macro variables after they are created. 

--
Paige Miller
ballardw
Super User

For one thing you create a pile of macro variables and do not assign any values to them.

 

One suspects that the macro variable Value_4_4 was created earlier, with different code, in such a manner that it appears in the GLOBAL table. Since the approach you are using with %dummy does not place the variable into the global table it is local and stops existing when the macro ends. Since we had a similar question from you earlier you might want to be aware that CALL SYMPUTX by default places everything into the global macro variable table.

Test whether other variables were earlier placed in the global table with:

%put _global_;

Depending on what you have done prior you might examine &value_1_8, &value_2_8 etc. I suspect you may find all of them undefined as well.

 

FWIW, I get the same Unresolved note about Value_4_4 (because I haven't run any code that placed it into the global table.

Patrick
Opal | Level 21

You need to populate your macro variables AND you need to define it as %global if you want to use it outside of your macro. 

Hope below will give you some guidance.

%let cnt_id_groups=5;
%let cnt_Id_value_groups=9;
%macro dummy;
  %global value_&cnt_id_groups._&cnt_Id_value_groups;
  %do i = 1 %to &cnt_id_groups.;
  	%do j=1 %to &cnt_Id_value_groups.;
  		%let value_&i._&j=%eval(&i * &j);
  	%end;
  %end;
  %put last_iter_macro var name:  value_&cnt_id_groups._&cnt_Id_value_groups;
  %put last_iter_macro var value: &&value_&cnt_id_groups._&cnt_Id_value_groups;
%mend dummy;
%dummy;

%put value_&cnt_id_groups._&cnt_Id_value_groups: &&value_&cnt_id_groups._&cnt_Id_value_groups;

Patrick_0-1711075516967.png

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 400 views
  • 2 likes
  • 4 in conversation