DATA Step, Macro, Functions and more

Help with the following

Reply
Contributor
Posts: 60

Help with the following

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.
Frequent Contributor
Posts: 139

Re: Help with the following

Posted in reply to sasuser1000
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
Contributor
Posts: 60

Re: Help with the following

Posted in reply to darrylovia
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.
Contributor
Posts: 60

Re: Help with the following

Posted in reply to sasuser1000
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.
Super Contributor
Super Contributor
Posts: 365

Re: Help with the following

Posted in reply to sasuser1000
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
Contributor
Posts: 60

Re: Help with the following

Yes, this is what I need as an upper value, but SAS doesn't accept the code..
Super Contributor
Super Contributor
Posts: 365

Re: Help with the following

Posted in reply to sasuser1000
Please give relevant code of you macro and error messages you got.

SPR
Ask a Question
Discussion stats
  • 6 replies
  • 843 views
  • 0 likes
  • 3 in conversation