Date: Thu, 29 Jan 2004 11:35:13 CET
Reply-To: datametric@CLUB-INTERNET.FR
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: SUBSCRIBE SAS-L Stephane <datametric@CLUB-INTERNET.FR>
Subject: Re: RE : a question of End SAS macro
Content-Type: text/plain; charset=ISO-8859-1
Really ?
could you explain this ?
----Message d'origine----
>Date: Wed, 28 Jan 2004 17:44:42 -0700
>De: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>
>Sujet: Re: RE : a question of End SAS macro
>A: SAS-L@LISTSERV.UGA.EDU
>
>Just remember that the dictionary table entries won't always be accurate.
>
>
>
>--
>JackHamilton@FirstHealth.com
>Manager, Technical Development
>Metrics Department, First Health
>West Sacramento, California USA
>
>>>> "Choate, Paul@DDS" <pchoate@DDS.CA.GOV> 01/28/2004 4:24 PM >>>
>Stéphane-
>
>You jogged my memory of another method to quickly get the number of obs
>posted by Jim Groeneveld a little while back...
>
>DATA _NULL_;
> IF 0 THEN SET dataset NOBS=NrOfObs;
> CALL SYMPUT ('NrOfObs', PUT(NrOfObs, BEST12.));
> STOP;
>RUN;
>
>It essentially does exactly what your
>
>%let v_op_table = %sysfunc(open(a&name.&site.));
>%let v_obs_table = %sysfunc(attrn(&v_op_table, nobs));
>%let v_cl_table =%sysfunc(close(&v_op_table));
>
>does: opens the tables, reads the NOBS attribute, and closes the table.
>
>Both are much faster than my method of using proc sql noprint to extract the
>nobs value from dictionary.tables, especially if there are a large number of
>tables.
>
>Regards....
>
>Paul Choate
>DDS Data Extraction
>(916) 654-2160
>
>-----Original Message-----
>From: Datametric [mailto:datametric@CLUB-INTERNET.FR]
>Sent: Wednesday, January 28, 2004 3:30 PM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: RE : a question of End SAS macro
>
>Hi,
>
>You should try this :
>
>%macro check(name,site);
>
>libname lib "..... ";
>
>data a&name.&site.;
>set lib.&name. (where=(site=&site.));
>run;
>
>/* use this for each datastep. this is a generic message */
>%if &syserr > 0 %then %let v_err= error on "&syslast";
>%if &syserr > 0 %then %goto err_step;
>
>
>/* for the nobs */
>%let v_op_table = %sysfunc(open(a&name.&site.));
>%let v_obs_table = %sysfunc(attrn(&v_op_table, nobs));
>%let v_cl_table =%sysfunc(close(&v_op_table));
>
>%if &v_obs_table = 0 %then %let v_err = data "a&name.&site." is empty;
>%if &v_obs_table = 0 %then %goto err_step;
>
>/* continue */
>there are more data steps from here..
>...
>...
>...
>...
>...
>...
>
>/* if it's right, you have to jump de err_step label used to generic error
>message */
>%put check is OK;
>%goto end;
>
>/* label inidcates error, and could contains a global variable used for
>return code (RC) if %check is called by an another macro */
>
>%err_step:
>%let rc=4;
>%put &v_err;
>%put the macro &sysmacroname is stopped;
>
>%end:
>
>%mend check;
>
>You should use the abort statement but it's more violent.
>
>Stéphane.
>
>
>-----Message d'origine-----
>De : SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] De la part de miranda
>Envoyé : mercredi 28 janvier 2004 21:59
>À : SAS-L@LISTSERV.UGA.EDU
>Objet : a question of End SAS macro
>
>
>Hi,
>I have a SAS macro like this:
>
>%macro Check(name,site);
>
>libname lib "..... ";
>
>data a&name.&site.;
>set lib.&name.;
>if site=&site.;
>run;
>
>My question is : How could I stop my macro running here If the data set is 0
>obs and the further data steps won't run?
>
>
>There are more data steps from here..
>...
>...
>...
>...
>...
>...
>%mend Check;
>
>
>Thanks.
>
>
|