Help using Base SAS procedures

what's wrong with this piece of code

Reply
Contributor
Posts: 24

what's wrong with this piece of code

Hi all,

I got error msg after running the following code. Can anyone please help debug. Thanks in advance.


%MACRO MYSQL;
PROC SQL;
SELECT COUNT(*) INTO :MYCNT FROM MYTABLE;
%LET MYCNT = &MYCNT;
DATA _NULL_;
IF &MYCNT > 1 THEN %MYPRINT(MYTABLE,'MYTABLE');
RUN;
%MEND MYSQL;

%MACRO MYPRINT(MYDATA,TN);
PROC CONTENTS DATA = &MYDATA POSITION;
TITLE 'Contents of ' &TN;
RUN;
PROC PRINT DATA=&MYDATA (OBS=10) U;
RUN;
%MEND MYPRINT;


%MYSQL;

RUN;
Super Contributor
Posts: 281

Re: what's wrong with this piece of code

PROC CONTENTS cannot be called from within DATA _NULL_;

Instead of your DATA _NULL_ step, the following should work

%IF &MYCNT > 1 %THEN %MYPRINT(MYTABLE,'MYTABLE');
Contributor
Posts: 24

Re: what's wrong with this piece of code

from the replied tips, it apperas that adding % takes care of it.

Thank all who replied.
Regular Contributor
Posts: 165

Re: what's wrong with this piece of code

It would be helpful to see the error message as well as the code that came before it in the SAS log.
Ask a Question
Discussion stats
  • 3 replies
  • 92 views
  • 0 likes
  • 3 in conversation