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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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