Date: Tue, 2 Nov 2004 11:02:44 -0500
Reply-To: "Ross, Michael D" <michael.ross@ASTRAZENECA.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Ross, Michael D" <michael.ross@ASTRAZENECA.COM>
Subject: Re: Global Count!
Content-Type: text/plain; charset="iso-8859-1"
Thanks Toby.
One more question, I'm looking to put these "count" variables into one
dataset, so that I can report on them down the road. Is there a way to
accomplish this in the "freq" macro or do I need another macro?
I appreciate your help - Thanks!
Mike
-----Original Message-----
From: Dunn, Toby [mailto:Toby.Dunn@TEA.STATE.TX.US]
Sent: Monday, November 01, 2004 4:58 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Global Count!
Ross, try this:
%macro freq(path=,ds=) ;
%global countall ;
proc freq
data = &path..&ds noprint ;
tables trial/ out = &ds (keep = count rename=(count=count_&path.&ds))
;
run ;
%let countall = %eval(&countall + 1) ;
%mend freq ;
%freq(path=prior, ds=xxx) ;
%freq(path=prior, ds=yyy) ;
Should get you a count of the number of time the macro ran;
It won't however get you a count of the number of obs. in a dataset. To
do that you need to do the following:
data one ;
do x = 1 to 10 ;
Output ;
End ;
Run ;
proc sql ;
select nobs into : obs_cnt
from dictionary.tables
where memname = "ONE" ;
Quit ;
%put &nobs ;
Will get you the number of physical obs in a dataset.
Now what about the case where you might have marked some for deletion:
proc sql ;
select delobs into : obs_cnt
from dictionary.tables
where memname = "ONE" ;
Quit ;
%put &nobs ;
HTH
Toby Dunn
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Ross, Michael D
Sent: Monday, November 01, 2004 3:33 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Global Count!
Hi All,
I need to get a count everytime through this macro, ending up with the
total number of times I went through it. Any suggestions?
Also, is this the best way to do counts? I need to count observations
in various datasets and present a report.
%macro freq(path=,ds=);
%global count ;
proc freq data = &path..&ds noprint;
tables trial/ out = &ds (keep = count
rename=(count=count_&path.&ds)) ;
run ;
%let &countall=&count+1;
%mend freq;
%freq(path=prior, ds=xxx);
%freq(path=prior, ds=yyy);