BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have this macro in the beginning of my program:
%macro m1;
%do i=1 %to 10;
%let row&i=&i;
%end;
%mend;
%m1;

With %put &&row&i inside the macro I have checked that the values of row1 to row10 are from 1 to 10.

In my main program I have an expression

r&&row&k.col(n)=p; (a dot between k and c)

&k is a macro variable ranging from 1 to 10. n is a number from 1 to 5.
I have arrays r1col(5), r2col(5), ... , r10col(5) declared.

I expected to get r1col(n)=p, r2col(n)=p, ... and so on.

But I get the error message: Apparent symbolic reference ROW1COL not resolved.

The same for ROW2COL, and so on.

What have I done wrong?
5 REPLIES 5
Patrick
Opal | Level 21
You have two iterations until the macro var gets resolved. For every iteration a dot is consumed.
You need 2 dots.

%let row1=1;
%let k=1;

%put r&&row&k..com(n)=p;

HTH
Patrick
deleted_user
Not applicable
After adding the dot i get the warning(s): Apparent symbolic reference ROW1 not resolved.

Error message concerning r&row1.col: Statement is not valid or it is used out of proper order.
Flip
Fluorite | Level 6
Check to make sure &row1 is global. It looks like a local variable to you macro.
You would need to have %global row&i ; in your macro.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
We're back to the MACRO VARIABLE SCOPING topic, which came up in a prior post/thread.

Your macro creates a macro variable, which by default is LOCAL, however your SAS program attempts to reference a macro variable, so now your macro variables must be declared as GLOBAL type.

Scott Barry
SBBWorks, Inc.

SAS Macro Language: Reference, Scopes of Macro Variables
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002047080.htm


SAS Macro Language: Reference, Introduction to Macro Variables
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a002293823.htm
Flip
Fluorite | Level 6
We need a list of FPQ Frequently posted questions.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 836 views
  • 0 likes
  • 4 in conversation