03-17-2016 10:12 AM
Is there a function to determine the type of a library member? I don't want to use dictionary tables (this information is in sashelp.vmember) but instead want to use (if possible) a funtion. For example:
type = function('work.sasmacr');
would print 'CATALOG' to the log.
03-17-2016 03:37 PM
03-17-2016 10:25 AM
There isn't a function for this, why would you need one, there is only datasets and catalogs? Use the metadata libraries to ascertain these, why not?
data _null_; set sashelp.vmember (where=(libname="SASHELP" and MEMNAME="AC")); put memtype; run;
03-17-2016 11:49 AM
Using SCL I want to delete all member from the work library. This is my program:
dcl sashelp.classes.sasfilelist_c.class memobj;
dcl num rc i memcount;
dcl char member;
memobj = _new_ sashelp.classes.sasfilelist_c();
memobj.library = 'work';
memcount = memobj._count();
do i = 1 to memcount;
rc = delete(member);
But this will only delete data sets because the 'delete'-function takes as second argument the member type (default is data set). So I need to know the member type to pass to the delete statement in order to delete all members.
I could do this in a submit-block using proc datasets but I don't want anything to appear in the log or log buffer.
By the way in response to RW9: there are more types than only data and catalog, for example view, mddb etc.
03-17-2016 12:22 PM
Ah, so your using SAS/AF. I am afraid I haven't used that in many years, hadn't thought anyone was still using it. I would suggest your best bet is still to do this in SAS code. Best of luck.
03-17-2016 02:51 PM
You could use the EXIST function on each member name. By default this checks for datasets. If it returns a 0 return code then you can assume that the member type is not DATA so you could then try EXIST for the member type CATALOG. It's a bit clunky but should work.
03-18-2016 03:36 AM
If you want to hide your actions from the log, consider writing a shell script and calling that with call system or X.
03-17-2016 03:37 PM
03-18-2016 10:52 AM
Yes, I probably have to use dictionary tables. I'll solve it that way in combination with Ksharp's suggestion and write my own funtion.
03-18-2016 07:57 PM
this page contains code for each of the existence functions
I am still unclear how you are going to use this knowledge.
if you have a list of filename.ext of the files in a Windows folder,
then the extention tells you the type:
Ron Fehd reuse maven
03-21-2016 06:57 AM
I am not interested in the existence, I know already the member exists. I want to know the type of a library member. As explained earlier I need that information because I want to delete member from SCL. And the scl delete function takes two arguments: name (the name of member to delete) and type (the type of member to delete).
03-21-2016 07:34 AM
If you have a variable MEMNAME with the name of the member then just loop over values of MEMTYPE in DATA, CATALOG, VIEW, ... and call the EXIST() function with MEMNAME and MEMTYPE until you find out what MEMTYPE to use for the call to the DELETE() function.
03-21-2016 12:49 PM
That's not a very robust solution: what if SAS introduces a new type? Then you have to change the program to include the name of that new type. I prefer to use the dictionnary tables.
Need further help from the community? Please ask a new question.