Date: Thu, 10 Feb 2005 23:13:18 -0500
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: Proc options error handling
SASHELP.VMEMBER and DICTIONARY.MEMBERS will pass the invalid names and will
not raise the ERROR condition which PROC CONTENTS does. I think that's
because only PROC CONTENTS actually opens the data sets. That's also why
P.C. gives you the observation counts; the other metadata vehicles do not.
You could retrieve all of the names, using SASHELP.VMEMBER or
DICTIONARY.MEMBERS, then filter out the bad ones. I don't think there is a
function which validates SAS names, but it should not be too hard using
available functions or perhaps a regular expression.
Then you would have to go back to PROC CONTENT for the obsevation counts.
That would probably take a macro.
Or maybe there is an easier way.
On Thu, 10 Feb 2005 11:03:51 -0500, Martin O'Connell <moconnell@GEICO.COM>
wrote:
>Hi all,
>
>I need to get a listing of SAS files in a library and for each file I need
>the number of obs in each. This I do by:
>
>proc datasets memtype=data nolist;
> contents data=mylib._all_ out=mylibcontents (keep=memname nobs) noprint;
>quit;
>
>Normally this works fine. But this morning another developer renamed a
>member dataset_1 to dataset-1 which caused my code to fail. He did this
>outside of SAS (using OS commands).
>
>My question is this: Can I guard against this condition in the sense that
>the offending dataset(s) will be skipped in the output? I am only after
>info on my files (this is a shared directory) which I know will be rightly
>named.
>
>Thanks much for any help.
>
>Martin