Is there any method, where I can extract dataset name from expressions like:
<work.ds(...where=(...))>
<ds(... where=(...))>
or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?
@TimurShangareev wrote:
Is there any method, where I can extract dataset name from expressions like:
<work.ds(...where=(...))>
<ds(... where=(...))>
or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?
Let me make sure I am understanding. You have some text, like
SASHELP.CLASS(where=(sex='F'))
and you want to determine the data set name (which is SASHELP.CLASS). Is that what you want?
Where do you want to do this? (In a SAS data step? Somewhere else?)
What is the source of the input text string?
@TimurShangareev wrote:
Is there any method, where I can extract dataset name from expressions like:
<work.ds(...where=(...))>
<ds(... where=(...))>
or somehow check that this expression is valid in macro calls (wthout PROC or DATA statements)?
It would help if you explained in more detail what you actually mean. Perhaps some example use cases would help?
You mentioned macro calls. So in macro code here are a couple of simple things.
%let dsn=sashelp.class(where=(age>11));
%let valid=FALSE;
%let dsid=%sysfunc(open(&dsn));
%if &dsid %then %do;
%let valid=TRUE;
%let dsid=%sysfunc(close(&dsid));
%end;
%let name_only=%scan(&dsn,1,());
%let options=%substr(&dsn%str( ),%length(&name_only)+1);
%let memname=%scan(&name_only,-1,.);
%let libref=%scan(WORK.&name_only,-2,.);
%put &=dsn &=valid ;
%put &=name_only &=options;
%put &=libref &=memname ;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.