SAS command Apply Advanced Skill - How to find or replace a string from a batch of SCLs, Source files
Do you have such a trouble, you have built hundred SCL or SOURCE files in a good Catalog, suddenly one day because the system changes, you must change the program, such as some feature is quoted by a large number of programs, then you must one Open the SCL file, then look up, then in replace, I want you to hate the SAS company's break editor, the function is like Microsoft's notepad, if you don't know such a skill, it can only be old Open, find, replace, compile, save, save, then open another file, resoluntary this week, but fortunately, you see this article, from now on, you can say full of BOSS. I absolutely changed all the changes, no problem, I don't know how to return, I don't know if you have used a big name Ding Ding editor UltraEdit, I believe many people who write CODE are using it, indeed Very strong editor, today I use a small feature in this editor, that is, find, replace the function, it can find replacement in N multi-file, I tried, open hundred file speed Still good, and the operation is very convenient, know if this feature is OK, how is the following problem be introduced to the program files in SAS Catalog? And listen to me slowly, first, we know, SAS provides a lot of shortcomings direct operation, such as tapping an [Open table name in the command window, you can open a table without using the mouse to find this table name , Then double-click to implement the program files under Catalog, import us must know these commands, as follows the build SCL file / * Open a SCL file * / clean / * Clear the current window content * / file "file name" / * store current Window content to file * / include "file name" / * imported the contents of the specified file * / compile / * Compile the current program * / save / * save the current window content * / saveclass / * save is class * / end / * Close the current window * / can / * Cancel the changes made by the current window * / must also know such a SAS system view, which is SAS file information, such as what files under Catalog, what type of type is Ah, the following system view Sashelp.vcatalg main field: libName library name, the name of Catalog's name MemName directory name Objtype member type, such as the SCL ObjName object name, is the file under Catalog
Ok, I know these, you can guide the files you want. The source code is / * export * /% Let Dir = g: / src /; / * To export * / data _null_; set Sashelp.vcatalg; WHERE libName = "To export the library" and Memname IN (what type of directory to export) and objtype = "What type of file is to be exported, such as SCL, such as SCL"; Length FileName FileName1 $ 200 STR $ 2000; FileName = Compress ("& Dir "|| Memname ||" / "||" .scl "); filename1 = compress (libname ||". "|| memname ||". "|| ObjName ||" .scl "); STR = "DM" "||" build "|| Trim (filename1) ||"; file "||" "|" "| |" ";" | | | " ";"; PUT STR; Run; OK, now running the above program, output DM "build ***. SCL; File'g: / src / ***. SCL '; end;"; DM " Build ***. SCL; File'g: / src / ***. SCL '; END; "; .... then copy the output results, then paste it to the command window, run, then you will see The window flashes, if the file is full of the file, it is patient, and then goes to the directory you exported. If you have a lot of SCL files, the first step is big.
The second step is of course the derived file for operation. What do you want to do, what is the powerful UltraEdit, batch query, replacement is a piece of cake.
Ok, assume that all your changes should be better. Of course, how to write the result of the change in SAS, very simple, is to change the above output results, then run in the SAS command window Will automatically write all the Catalog of SAS, as follows
/ * Import * / dm "build ***. SCL; CLEAR; include '***. SCL'; save; compile; saveclass; end;" Look, even Complie, SaveClass gives you, satisfying This article is here for OVER, please use it, but look at it when it is reproduced, grateful :)