1 / 8

“Find It” Using SAS

“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 I want to search for the literal “libname”, because I want to see what libname statements are in the code.

raziya
Download Presentation

“Find It” Using SAS

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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. 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 */ • okagent2.run /reference/code libname gsdata sasspds "gsdata" host= "ga016dxx" • okagent2.run /reference/code libname ext sasspds “ext" host= "ga016dxx"

  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 http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002267763.htm

More Related