BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Roland_N
Calcite | Level 5

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20
If it's important not to use submitted Sas code, you could browse sashelp.vmember by function calls. Very awkward IMO but should meet your requirements.
Data never sleeps

View solution in original post

13 REPLIES 13
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
LinusH
Tourmaline | Level 20

No, not in the function list.

Please state why you don't wish to use system tables.

Data never sleeps
Roland_N
Calcite | Level 5

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

SASKiwi
PROC Star

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.

LinusH
Tourmaline | Level 20
If it's important not to use submitted Sas code, you could browse sashelp.vmember by function calls. Very awkward IMO but should meet your requirements.
Data never sleeps
Roland_N
Calcite | Level 5

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.

Ksharp
Super User

Or Maybe you could use PROC FCMP + dictionary table to build such function .

Ron_MacroMaven
Lapis Lazuli | Level 10

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

Roland_N
Calcite | Level 5

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).

Tom
Super User Tom
Super User

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.

Roland_N
Calcite | Level 5

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 13 replies
  • 1536 views
  • 0 likes
  • 8 in conversation