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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 610 views
  • 0 likes
  • 2 in conversation