BookmarkSubscribeRSS Feed
sasuser1000
Calcite | Level 5
Hi,

i cant make this work and it's very urgent, please help!

this is the log :

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric
operand is required. The condition was: &NOBSI
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro ADJUST will stop executing.




This is the code:




data _null_;
set list1 nobs=nobs;
call symputn ('NOBSI',nobs);
stop;
run;


%macro ADJUST(NOBSI);

%do I=1 %TO &NOBSI;
.etc
.etc
.etc
.
%end;

%mend; /*end of macro*/

/* here I create a datastep in order to be able to use symget

data A;
NOBSI=SYMGETn ('NOBSI');

%ADJUST(NOBS) ;

RUN;
2 REPLIES 2
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello SASUser1000,

I found 2 problems with your code:

1. In data _null_; it should be call symputx ('NOBSI',nobs);
2. In data A it is impossible to create macro variable and use it in the same datastep.

This is a correct veriosn of your program:
[pre]
data list1;
do i=1 to 10;
output;
end;
run;
data _null_;
set list1 nobs=nobs;
call symputx ('NOBSI',nobs);
stop;
run;


%macro ADJUST(NOBSI);
%local i;
%do I=1 %TO &NOBSI;
%put i=&i;
%end;
%mend; /*end of macro*/

%adjust(&nobsi)
[/pre]

Sincerely,
SPR
sasuser1000
Calcite | Level 5
Dear SPR!

Thank you so much, it worked!

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1041 views
  • 0 likes
  • 2 in conversation