BookmarkSubscribeRSS Feed
scb
Obsidian | Level 7 scb
Obsidian | Level 7

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

 

 

 

 

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

What do you mean by the owner? 🙂

scb
Obsidian | Level 7 scb
Obsidian | Level 7

The creator of the SAS dataset.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

scb
Obsidian | Level 7 scb
Obsidian | Level 7

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

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

PeterClemmensen
Tourmaline | Level 20

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

PeterClemmensen
Tourmaline | Level 20

Unless the code is properly documented, which of course all code is 😉

Kurt_Bremser
Super User

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

FK1
Lapis Lazuli | Level 10 FK1
Lapis Lazuli | Level 10

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

 

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
  • 9 replies
  • 5319 views
  • 0 likes
  • 5 in conversation