Hi SAS team!
My code was like this:
%macro a;
data sample1;
a=1;
run;
data lack;
run;
%let s1=%sysfunc(open(sample1));
%let lk=%sysfunc(open(lack));
%if &s1>0 and &lk>0 %then %do;
%put &s1 &lk;
%end;
%else %do;
%put "one of the dataset can not be opened";
%end;
%let rc=%sysfunc(close(&s1));
%let rc=%sysfunc(close(&lk));
%mend a;
%a;
i expected that the note of "one of the dataset can not be opened" were written to the LOG, but the result was "1 2". Would anyone could explain how it happened and demonstrate the usage of OPEN function or other functions if the former note would be written.
Appreciate any help!
Qinly
You could try FETCH()
OPEN will return a file handle number. Hence the 1 and 2 that you see in the log.
They should both successfully open the datasets you just created .
Thank you, Tom. And if both data sets do exist, but one of them has no obs, just like data set lack, which function could achieve my purpose?
You could try FETCH()
Thank you, Tom! I've solved it by your suggestion.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.