Presentation is loading. Please wait.

Presentation is loading. Please wait.

Find It Using SAS By David Steves. Would you like to be able to search SAS programs for certain expressions? Example: I have a list of SAS programs which.

Similar presentations


Presentation on theme: "Find It Using SAS By David Steves. Would you like to be able to search SAS programs for certain expressions? Example: I have a list of SAS programs which."— Presentation transcript:

1 Find It Using SAS By David Steves

2 Would you like to be able to search SAS programs for certain expressions? Example: I have a list of SAS programs which I want to search for the literal libname, because I want to see what libname statements are in the code.

3 libname unix1 '/home/unix1'; sample of unix1.list_programs ; Obs code map_directory 1 okagent.run /reference/code 2 okagent.sas /reference/code 3 okagent2.run /reference/code 4 okagent2.sas /reference/code 5 actinv.run /outbound_extracts/code

4 Sample of output Obs program directory list 1 2 okagent2.run /reference/code # as tt1 libname 3 okagent2.run /reference/code libname tt1 '/prodtemp'; 4 okagent2.run /reference/code /* change on 11/27 to spds4 libname */ 5 okagent2.run /reference/code libname gsdata sasspds "gsdata" host= "ga016dxx" 6 okagent2.run /reference/code libname ext sasspds ext" host= "ga016dxx"

5 data _null_; set unix1.list_programs end=no_more; call symput('mapto'||left(_n_),map_directory); call symput('program'||left(_n_),code); if no_more then call symput('pgcnt',_n_); run; %put &pgcnt.; ** Creation of SAS DATASET –no observations yet*; data all_prod; format program $35. directory $35. list $80.; run;

6 %macro progloop; %local i; %do i=1 %to &pgcnt; %macro search(dir,ftoconv); data tt1; infile "/source/&dir/&ftoconv." lrecl=32767 end=_eof; input; INPUT statement with no arguments. _infile_ automatic variable find_it1 = find(_infile_,'libname','I'); *I ignores Character case*; format program $35. directory $35. list $80.; program="&ftoconv."; directory="&dir."; if find_it1 > 0 then list= _infile_; if find_it1 > 0; run; proc append base=all_prod data=tt1(keep=directory program list) force; run; %mend search; %search(&&mapto&i,&&program&i); %end; %mend progloop; %progloop;

7 Obs program directory list 1 2 okagent2.run /reference/code # as tt1 libname 3 okagent2.run /reference/code libname tt1 '/prodtemp'; 4 okagent2.run /reference/code /* change on 11/27 to spds4 libname */ 5okagent2.run /reference/code libname gsdata sasspds "gsdata" host= " ga016dxx" 6okagent2.run /reference/code libname ext sasspds ext" host= "ga016dxx" Sample of output

8 Interesting points Take this code and check for other expressions Use this SAS code to scan other non-SAS programs Ability to make decisions with scan results More Info about the find function go to htm htm


Download ppt "Find It Using SAS By David Steves. Would you like to be able to search SAS programs for certain expressions? Example: I have a list of SAS programs which."

Similar presentations


Ads by Google