May I know how to find the owner of a SAS dataset in SAS codes? Any example? Thanks.
What do you mean by the owner? 🙂
The creator of the SAS 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.
The creator of the SAS dataset. Please refer to the file.
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.
I'm not sure about other applications, but it is not available in Base SAS at least 🙂
Unless the code is properly documented, which of course all code is 😉
"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.
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:
Cheers,
FK
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.