Verifies the existence of a SAS library member.
| Category: | SAS File I/O |
is a character constant, variable, or expression that specifies the SAS library member. If member-name is blank or a null string, then EXIST uses the value of the _LAST_ system variable as the member name.
is a character constant, variable, or expression that specifies the type of SAS library member. A few common member types include ACCESS, CATALOG, DATA, and VIEW. If you do not specify a member-type, then the member type DATA is assumed.
is a numeric constant, variable, or expression that specifies the generation number of the SAS data set whose existence you are checking. If member-type is not DATA, generation is ignored.
%let dsname=sasuser.houses; %macro opends(name); %if %sysfunc(exist(&name)) %then %let dsid=%sysfunc(open(&name,i)); %else %put Data set &name does not exist.; %mend opends; %opends(&dsname);
data new(genmax=3);
x=1;
run;
data new;
x=99;
run;
data new;
x=100;
run;
data new;
x=101;
run;
data _null_;
test=exist('new', 'DATA', 4);
put test=;
test=exist('new', 'DATA', 3);
put test=;
test=exist('new', 'DATA', 2);
put test=;
test=exist('new', 'DATA', 1);
put test=;
run;data new2(genmax=3);
x=1;
run;
data new2;
x=99;
run;
data new2;
x=100;
run;
data new2;
x=101;
run;
data _null_;
test=exist('new2', 'DATA', 0);
put test=;
test=exist('new2', 'DATA', -1);
put test=;
test=exist('new2', 'DATA', -2);
put test=;
test=exist('new2', 'DATA', -3);
put test=;
test=exist('new2', 'DATA', -4);
put test=;
run;