LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2009, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 28 Sep 2009 18:34:08 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Macrotrouble - ERROR: Required operator not found in
              expression
Comments: To: rune@FASTLANE.NO

Anaconda,

I agree with Barry, but I think you have even more things to resolve. You appear to be mixing macro and non-macro calls, but without specifying a data step.

The following works, but probably doesn't do what you really want to accomplish:

%macro nobs(dsn); data _null_; %if %sysfunc(exist(&dsn)) %then %do; dsid = open("&dsn"); nobs = attrn(dsid, "nlobs"); %end; %else nobs = . ; put dsid; put nobs; rc = close(dsid); run; %mend; %nobs(Sashelp.Class)

In short, more information is needed for anyone on the list to give you better direction.

Art -------- On Mon, 28 Sep 2009 13:40:29 -0700, Anaconda <rune@FASTLANE.NO> wrote:

>The macro below is supposed to check if a dataset exists or not. And >if it exists, then count the number of observations in it. What does >the error message in the SAS log mean? > >- Anaconda > >%macro nobs(dsn); > %if exist("&dsn") %then %do; > dsid = open("&dsn", "i"); > nobs = attrn(dsid, "nlobs"); > %end; > %else nobs = . ; > rc = close(dsid); >%mend; >%nobs(Sashelp.Class) ; > > >/* >14353 %macro nobs(dsn); >14354 %if exist("&dsn") %then %do; >14355 dsid = open("&dsn", "i"); >14356 nobs = attrn(dsid, "nlobs"); >14357 %end; >14358 %else nobs = . ; >14359 rc = close(dsid); >14360 %mend; >14361 %nobs(Sashelp.Class) ; >ERROR: Required operator not found in expression: exist("&dsn") >ERROR: The macro NOBS will stop executing. > > >*/


Back to: Top of message | Previous page | Main SAS-L page