An alternative way of performing a case-insensitive search is to use the regex construction /pattern to be matched/i. When CASE=I, you will get the largest set of matches. The line of characters read from the file will be matched against the regex. In this case (sorry), it will not matter whether or not the line in the file is UPPER-CASE or lower-case or Mixed-Case. If CASE=I, then a case-insensitive search will be performed. See the Full Code tab for the entire code, and the Downloads tab for a link to download the SAS program. , SUBDIR=Y /* switch to search subdirectories */ , REPORT=Y /* switch to create results of search */ , OUT= /* name of dataset containing results */ , LS=120 /* line size for printing results */ , PRX /* Perl regex used to match strings */ ( PATH /* Windows path to directory to search */ Based on %SASGREP control flags, the matched lines and descriptive information are printed to the list file. If there is a match found in the line scanned, the entire line and descriptive information are stored in a SAS dataset. Each line is parsed and scanned using the Perl regex functions PRXPARSE and PRXMATCH. In the second step, the files in each directory are opened and read into a SAS character variable, line-by-line. The path, filename, and descriptive information are stored in a SAS dataset. In the first step, a list of files is produced by using the pipe device type on a FILENAME statement to extract the contents of a directory path. AlgorithmĪ two-step approach is used in %SASGREP. The implementation discussed below uses the DOS DIR command as implemented in Windows XP, but with minor changes, the strategy employed can be used on other Windows operating systems, or on UNIX-based systems. It uses the Perl regular expression (regex) enhancements to the SAS DATA step available in SAS ®9. It has capabilities similar to the UNIX GREP (Global Regular Expression Print) utility from which it derives its name. ![]() ![]() A macro, %SASGREP, has been written to manage the process of searching a directory structure for text strings contained in files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |