I wanna get the label of dataset which is in the set
statement but I haven't find a beautiful method.
I have tried this:
data test;
set sashelp.class;
rc = open("sashelp.class");
label = attrc(rc,"label");
rc = close(rc);
run;
It works but also have a weak point that I have to write the name of dataset in open()
function.
I am looking for a better way to replace writing it manually since I have dozens of similar steps.
I have tried &syslast
too, but it doesn't work. May there is some way else?
Maybe INDSNAME
18 data _null_;
19 set sashelp.class(obs=2 drop=_all_) sashelp.shoes(obs=2 drop=_all_)indsname=indsname;
20 retain label;
21 if indsname ne lag(indsname) then do;
22 rc = open(indsname); label=attrc(rc,"label"); rc=close(rc);
23 end;
24 put _all_;
25
26 run;
indsname=SASHELP.CLASS label=Student Data rc=0 _ERROR_=0 _N_=1
indsname=SASHELP.CLASS label=Student Data rc=. _ERROR_=0 _N_=2
indsname=SASHELP.SHOES label=Fictitious Shoe Company Data rc=0 _ERROR_=0 _N_=3
indsname=SASHELP.SHOES label=Fictitious Shoe Company Data rc=. _ERROR_=0 _N_=4