Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table Ownership

Status
Not open for further replies.

shenniko

Programmer
Apr 15, 2005
52
US
Hi All,

Need a bit of help.

Is there a way to list all tables that I own in a Library?

The reason for this is because our SAS admin have decided to make it so that only the people who created the table, can make changes to it..

So.. I want to make a little program that looks in a Library and sets the chmod to 777 for all tables i own. And then pass that program onto other members of the team so they can do the same to their tables.

thanks in advance

Robbie
 
Not sure if you use PC SAS or SAS on a server, but I use PC SAS. You could use DOS commands to see who the file owner is like so:
Code:
%LET DATA_LOC  = R:\SAS DATA\;

LIBNAME EXTRACT "&DATA_LOC";

%let infile = N:\REPORTS\file_list.txt;

options noxwait xsync; run;
x del "&infile";
RUN;

/********************************************************************/
/***  Create the new Directory Report and                         ***/
/***  delete existing excel document                              ***/
/********************************************************************/
options noxwait xsync; run;
x cd &DATA_LOC;
x dir > &infile /A:-D  /N /T:C /S /O:-D /Q;
RUN;



data WORK.LOG_LIST;
infile "&infile" missover LRECL=32000 RECFM=V FIRSTOBS=6;
ATTRIB CREATION_DATE     LENGTH=$10.;
ATTRIB TIME     LENGTH=$5.;
ATTRIB AM_PM    LENGTH=$2.;
ATTRIB NAME     LENGTH=$500.;
INPUT @001  CREATION_DATE   $10. @013  TIME   $5. @019 AM_PM $2. @040  User $23. @063  NAME  $ &;
IF CREATION_DATE NOT IN (' ','Total','Directory');
USER = COMPRESS(USER,'US\');
IF INDEX(NAME,".sas7bdat");
run;
 
Hey,

Sorry for late reply, but i managed to get it soretd, code will scan through library and find all tables crated by current user logged on, and change tables to 777. Code below:-

Code:
rsubmit;
	%global DSETs DSET_Count;

	filename lsinfo pipe 'cd /sas/data/techtm; ls -l';
	data techtm_files;
		infile lsinfo pad end=last;
		input rec $250.;
		dsn=scan(rec,-1,' ');
		owner=scan(rec,3,' ');
		permissions=scan(rec,1,' ');
	run;

	Data Limit_RW;
		set techtm_files(where=(permissions not in ("-rw-rw-rw-", "-rwxrwxrwx") and
								owner = "&sysuserid"));
	run;

	proc sql noprint;
		select distinct dsn into :DSETs separated by '*' from Limit_RW;
		select count(distinct dsn) into :DSET_Count from Limit_RW;	
	quit;

	%macro Change_RW();
		%if &DSET_Count. >=1 %then
			%do;
				%do i=1 %to &DSET_Count.;
				  filename chmod pipe "chmod 777 /sas/data/techtm/%scan(&DSETs., &i., "*")";
				  data _null_;
				     file chmod;
				  run;
				%end;
			%end;
	%Mend Change_RW;
	%Change_RW;
endrsubmit;
 
You could use Mdieckman's idea even on UNIX. Use the SASHELP.VMEMBER view and to get a list of sas tables\views and then execute the LS command on that list (and only keep the ones that 'meet' your reqs like 777) piping the output to a text file for further use.

You may need to play with the PATH value in that view as I noticed for Windows systems it does not have the file name in it only the path to the library. (Easily fixed)

Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top