Hello
I want to use finfo function to gather some information about the data set ,for example: who created it (user name), date it was last modifies and so on
I saw the following code but I need to adjust it.
I have library name R_R
and I have data set name MACHZOR_TBL_SOFI
In the code it is written differently as file path and library path
filename fileref "J:\Tests.csv";
filename filerefa "J:\Facilities.csv";
What is the way to use the code by usine library name and data set name?
Please note that library R_R path is
/usr/local/SAS/SASUsers/LabRet/Credit_Scoring_Users/R_R
filename fileref "J:\Tests.csv";
filename filerefa "J:\Facilities.csv";
data a(drop=fidlab fidreg);
infile fileref truncover obs=1;
infile filerefa truncover obs=1;
fidlab=fopen("fileref");
fidreg=fopen("filerefa");
moddatelab=input(finfo(fidlab,"Last Modified"),datetime.);
moddatereg=input(finfo(fidreg,"Last Modified"),datetime.);
crdatelab=input(finfo(fidlab,"Create Time"),datetime.);
crdatereg=input(finfo(fidreg,"Create Time"),datetime.);
labdate=datepart(max(moddatelab,crdatelab));
regdate=datepart(max(moddatereg,crdatereg));
format moddatelab moddatereg crdatelab crdatereg datetime. labdate regdate date9.;
CALL SYMPUTX("labtime",put(labdate,date9.)) ;
CALL SYMPUTX("regtime",put(regdate,date9.)) ;
run;
Use the FOPTNUM and FOPTNAME functions to get tge names of the available FINFO items.
UNIX does not have the concept of a "create time", BTW. Only the last modification is kept.
The filename of your dataset file would be
/usr/local/SAS/SASUsers/LabRet/Credit_Scoring_Users/R_R/machzor_tbl_sofi.sas7bdat
The names of available FINFO items for the different platforms are documented here: FINFO Function (Maxim 1)
Thanks
What is the difference between fileref and filerefa?
As I understand the purpose of the function is to check information about specific file (for example: when created and so on).
Why are there 2 files defined in the code?
filename fileref "J:\Tests.csv";
filename filerefa "J:\Facilities.csv";
Read the code.
It looks like you can not get table owner information by FINFO.
As @Tom said try PROC CONTENTS ,about other info you also could get them by PROC CONTENTS.
libname x 'c:\temp\a\';
ods select none;
ods output Attributes=want1 EngineHost=want2;
proc contents data=x.have varnum;run;
ods select all;
FINFO does return the owner:
libname mylib "/home/kurt.bremser/mylib";
data mylib.class;
set sashelp.class;
run;
data properties;
length name value $30;
rc = filename("ds","/home/kurt.bremser/mylib/class.sas7bdat");
fid = fopen("ds");
if fid /* fopen was successfull, otherwise fid would be 0 */
then do;
do i = 1 to foptnum(fid);
name = foptname(fid,i);
value = finfo(fid,name);
output;
end;
rc = fclose(fid);
end;
rc = filename("ds");
keep name value;
run;
proc print data=properties noobs;
run;
(executed on SAS On Demand)
Result:
name value Dateiname /home/kurt.bremser/mylib/class Besitzername kurt.bremser Gruppenname oda Zugriffsberechtigung -rw-r--r-- Zuletzt geändert 22. August 2024 12.09 Uhr Dateigröße (Byte) 262144
Note that the names and the last modification time are locale-dependent, so it would be better to get a certain item by its number:
value = finfo(fid,foptname(fid,i));
i should be 2 for the owner.
Operating system dependent. On a windows system running code pointing to a different file (obviously)
name value Filename X:\Data\IPP\Data\hd6_2024.sas7 RECFM V LRECL 32767 File Size (bytes) 131072 Last Modified 07Jun2024:09:55:26 Create Time 13Feb2024:14:27:56
@ballardw wrote:
Operating system dependent. On a windows system running code pointing to a different file (obviously)
name value Filename X:\Data\IPP\Data\hd6_2024.sas7 RECFM V LRECL 32767 File Size (bytes) 131072 Last Modified 07Jun2024:09:55:26 Create Time 13Feb2024:14:27:56
Well, CP/M never had the concept of an owner 😉
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.