DATA Step, Macro, Functions and more

How to find the file Owner information from the Operating System metadata.

Reply
Frequent Contributor
Frequent Contributor
Posts: 78

How to find the file Owner information from the Operating System metadata.

[ Edited ]

May I know how to find the owner of a SAS dataset in SAS codes? Any example? Thanks.

 

 

 

 

PROC Star
Posts: 1,215

Re: SAS query - Dataset Owner

What do you mean by the owner? Smiley Happy

Frequent Contributor
Frequent Contributor
Posts: 78

Re: SAS query - Dataset Owner

The creator of the SAS dataset.

Super User
Super User
Posts: 9,427

How to find creator of a Dataset

What software are you using?  In Base SAS this information is not available.  If your using one of the DI pakcages or something like that it may be in the metadata.  Please post your question in the relevant area and give your thread titles meaningful titles: "SAS Query", or "SAS Macro query" are not good thread titles.

Frequent Contributor
Frequent Contributor
Posts: 78

Re: SAS query - Dataset Owner

The creator of the SAS dataset.  Please refer to the file.

Super User
Super User
Posts: 9,427

Re: SAS query - Dataset Owner

What you show there is the operating system information, therefore you need to be able to execute command line syntax to access it:

filename tmp pipe 'dir "c:\temp" /q';

data want;
  length buff $2000;
  infile tmp;
  input;
  buff=_infile_;
run;
  

Do note however that that information is nothing to SAS, its also very easy to change that kind of information, so any process using that information is inherently flawed.  You are better off using a metadata control system like DI or something if you need to track creation/access etc.

PROC Star
Posts: 1,215

Re: SAS query - Dataset Owner

I'm not sure about other applications, but it is not available in Base SAS at least Smiley Happy

PROC Star
Posts: 1,215

Re: SAS query - Dataset Owner

Unless the code is properly documented, which of course all code is Smiley Wink

Super User
Posts: 9,919

Re: SAS query - Dataset Owner

"Owner" is not very specific

- is it the design owner

- is it (one of) the people who use it

- is it the userid used when physically writing the dataset file

- is it the userid used when registering table metadata

 

The dataset file format has no information for owner, AFAIK.

How to determine the physical userid depends on the operating system where SAS is used.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor FK1
Contributor
Posts: 40

Re: SAS query - Dataset Owner

Posted in reply to KurtBremser

You can use the "Finfo" (=file information item) function which is offered by SAS:

 

data info;
   length infoname infoval $60;
   drop rc fid infonum i close;
   rc=filename('abc','physical-filename');
   fid=fopen('abc');
   infonum=foptnum(fid);
   do i=1 to infonum;
      infoname=foptname(fid,i);
      infoval=finfo(fid,infoname);
      output;
   end;
   close=fclose(fid);
run;

Depending on the Operating System (Windows, UNIX, z/Os, etc.) you get some information bits about your DataSet. 

 

For more information:

http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p0cpuq4ew0d...

 

Cheers,

FK

 

Ask a Question
Discussion stats
  • 9 replies
  • 434 views
  • 0 likes
  • 5 in conversation