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');
put type=;
would print 'CATALOG' to the log.
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;
No, not in the function list.
Please state why you don't wish to use system tables.
Using SCL I want to delete all member from the work library. This is my program:
init:
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;
member= memobj._getItem(i);
rc = delete(member);
end;
memobj._term();
return;
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.
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.
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.
If you want to hide your actions from the log, consider writing a shell script and calling that with call system or X.
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.
Or Maybe you could use PROC FCMP + dictionary table to build such function .
this page contains code for each of the existence functions
http://www.sascommunity.org/wiki/Macro_Exist
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:
data: .sasbdat
catalog: sasbcat
Ron Fehd reuse maven
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).
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.