BookmarkSubscribeRSS Feed
sasuser1000
Calcite | Level 5
Hi,

This is only part of the code but my main problem in the do loop, does someone knows what am I doing wrong?


%macro ADJUST;
data _null_;
set list1 nobs=nobs;
call symput('nobsI',compress(put(nobs,11.)));
stop;
run;


%do I=1 %TO SYMGETn('nobsI');
.etc
.etc
.etc
.

This is the LOG:


ERROR: Required operator not found in expression: SYMGETn('nobs')
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro ADJUST will stop executing.
6 REPLIES 6
darrylovia
Quartz | Level 8
Hello
SYMGET is a macro function used in the DATA STEP only. I would just resolve your macro variable NOBS1 by substituting SYMBETn('oobs1') with &nobs1 and thata should do the trick.

D
sasuser1000
Calcite | Level 5
Hi Darrylovia!

Thanks so much for answering

but something went wrong when I did the changes, I think i didn't really understand what to change (I am kind of new in MACRO).

Here are the changes I have done:

%macro ADJUST;
data _null_;
set list1 nobs=nobs;
call symbetn('nobs1',compress(put(nobs,11.)));
stop;
run;


%do I=1 %TO &nobs1 ;/*change to total number of records in data6*/




LOG:


data _null_; set list1 nobs=nobs; call symbetn('nobs1',compress(put(nobs,11.))); stop
-------
251
1 ! ; run;

ERROR 251-185: The subroutine SYMBETN is unknown, or cannot be accessed. Check your spelling.
Either it was not found in the path(s) of executable images, or there was
incorrect or missing subroutine descriptor information.
sasuser1000
Calcite | Level 5
Sorry I meant to reply with this


%macro ADJUST;
data _null_;
set list1 nobs=nobs;
call symput('nobsI',compress(put(nobs,11.)));
stop;
run;


%do I=1 %TO SYMBETn('nobsI');

I still get an error:


ERROR: Required operator not found in expression: SYMBETn('nobsI')
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: The macro ADJUST will stop executing.
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello SASUser100,

Please explain what value do you want to use as an upper limit in your %do loop?

%do I=1 %TO &nobsI; will work correctly but is this what you need?

Sincerely,
SPR
sasuser1000
Calcite | Level 5
Yes, this is what I need as an upper value, but SAS doesn't accept the code..
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Please give relevant code of you macro and error messages you got.

SPR

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 6 replies
  • 3273 views
  • 0 likes
  • 3 in conversation