Date: Thu, 27 Jan 2005 08:07:43 -0500
Reply-To: michael@BASSETTCONSULTING.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Davis <michael@BASSETTCONSULTING.COM>
Subject: Re: How to check if a format exists?]
Content-Type: text/plain; charset=ISO8859-1
Hello Friends,
Don's last suggestion is a very good one. In a SUGI paper that I presented a while back on the SASHELP dictionary tables:
http://www2.sas.com/proceedings/sugi26/p017-26.pdf
there is the following snippet of code:
proc sql ;
create table aa as select *
from dictionary.catalogs
where objtype contains ’FORMAT’
and objname = ’TEST’ ;
quit ;
Change TEST to the format name and you should be good to go. You might want to investigate whether objtype is always FORMAT for the values you seek.
HTH.
Michael "Mad Doggy" Davis
Ambler, PA
michael@bassettconsulting.com
>
> From: Don Henderson <donaldjhenderson@HOTMAIL.COM>
> Date: 2005/01/27 Thu AM 01:19:04 EST
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: How to check if a format exists?
>
> Because for character formats the fourth node in the name is FORMATC, not
> FORMAT.
>
> proc format;
> value num 1="A";
> value $chr "A"="B";
> run;
> %put %sysfunc(cexist(work.formats.num.format));
> %put %sysfunc(cexist(work.formats.chr.formatc));
>
> There are also other fourth level nodes I believe for other types of
> "formats" (e.g., formats vs informats). I would suggest you build examples
> of all the types you are interested in and then open the catalog to see the
> types. Or run something like to see what is in the catalog:
>
> proc sql;
> select * from dictionary.catalogs where libname='WORK' and
> memname='FORMATS';
>
> HTH,
> -don h
>
>
> >From: Scott <usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU>
> >Reply-To: Scott <usenet739_yahoo_com_au@CRONKITE.CC.UGA.EDU>
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: Re: How to check if a format exists?
> >Date: Thu, 27 Jan 2005 15:58:22 +1100
> >
> >However, with further testing, it doesn't work with character formats:
> >
> >proc format;
> > value num 1="A";
> > value $chr "A"="B";
> >run;
> >%put %sysfunc(cexist(work.formats.num.format));
> >%put %sysfunc(cexist(work.formats.chr.format));
> >%put %sysfunc(cexist(work.formats.$chr.format));
> >
> >:-(
> >
> >Hi Toby, dictionary.formats does not exist.
> >
> >"Scott" <usenet739_yahoo_com_au> wrote in message
> >news:41f8657f$0$25513$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> > > Well, I did think of this:
> > >
> > > proc format;
> > > value xxx
> > > 1="A"
> > > ;
> > > run;
> > > %put %sysfunc(cexist(work.formats.xxx.format));
> > > %put %sysfunc(cexist(work.formats.yyy.format));
> > >
> > > Not as clean as the format function below, but may work. Let me know if
> > > you have any better ideas.
> > >
> > > Thanks,
> > > Scott
> > >
> > > "Scott" <usenet739_yahoo_com_au> wrote in message
> > > news:41f84cbd$0$25515$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> > >> Hi,
> > >>
> > >> I'd like to add some error trapping to a macro, trapping for the
> > >> (non)existence of a format and gracefully exit rather than having it
> >fall
> > >> over in a heap.
> > >>
> > >> What I want is the SCL function rc=format('formatname.','c'), but in
> >open
> > >> code or a data _null_ step. format doesn't appear to be one of the
> > >> functions that were made available to the data step or %sysfunc in
> >v8.x.
> > >>
> > >> Any ideas?
> > >>
> > >> Thanks,
> > >> Scott
> > >>
> > >
> > >
>
|