If you want to extract the SAS Code in a log file and store it in a dataset then the below code will help you In logs the SAS code will be preceded with line numbers. So first pick the lines which are starting with numbers. Here I stored the data in the variable Code1. If you need only the SAS Code with out the line numbers then use substr to extract only the code leaving the line numbers. Here I stored the same in the variable Code. There will be blank lines in the code and the blank spaces will be stored in the dataset as observations.We can exclude these observations by using the if condition. data SASCode; infile "path\logfilename.txt"; input dat $1000.; dat = _infile_; if substr(left(_infile_),1,1) in ('1','2','3','4','5','6','7','8','9','0') then code1 = _infile_; code = substr(code1,index(code1," ")); keep code; if code ne " "; run; If you want to export the code into any flat file then proc export data = SASCode outfile = "xxx" dbms= xxx replace; run;
... View more