Hi,
I am looking for one answer. I am not very good at regular expressions and prxmatch.
I have the full sas code in our dataset. I need to find out the library refernces for that dataset- have and create a dataset- want which will have all the library references excluding the 'work'. also it should look for other code as well and not just proc sql queries.
the code should also exclude all the other code.
Output required is in dataset want:
lib_name:
mkis
cad
cad
cdd
mkis
focus
Data have;
length query $200;
infile datalines truncover;
input query $char100.;
datalines4;
Proc SQL;
create table t1 as select a from mkis.ba, cad.bb,work.dd;
quit;
/* this is comment */
data abc;
set cad.old;
run;
Proc SQL;
create table t2 as select a from cad.t3 inner join work.t4 on t3.id=t4.Id ;
quit;
Proc SQL;
create table t5 as select a from mkis.t6 left join work.t7 on t6.id=t8.id left join focus.t8 on t6.id=t8.id;
quit;
;;;;
;
;;;;;;;
run;
thanks in advance.
Manjeet
Don't bother trying to write a code parser yourself, its a very complex thing. SAS provides functionality to do this now, it is by using the proc scaproc
http://www2.sas.com/proceedings/forum2008/006-2008.pdf
(Source Code Analyser Procedure).
I am not trying to parse the code here, i just wanted to find out the table/library name from the code in the dataset. i need to use those libraries to define their libname statements.
for example:
Proc SQL;
create table t1 as select a from mkis.ba, cad.bb,work.dd;
quit;
from the above code, i need to identify the 2 libaries- mkis and cad and write out their library name reference statemnts.
libname mkis "C0042.bsa.bsa.mkis.sas" disp=shr;
Yes, you are trying to parse the text here. Libraries and their use can come in many forms, have aliases, be used in includes, be used in macros etc. As I have said, it is a complex task, and a needless one as there is a procedure already designed for the task, called proc scaproc.
thanks for the reply.
PROC SCAPROC only works when you run the code right? We are actually migrating the code from SAS EG to base sas, so we have captured all the sas code inside a dataset, one sentence of sas code as one observation.
I am not running the sas code, this sas code is inside a dataset and code will be in turn return to the one sas file, including the library refernces if we are able to find one.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.