- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm having arround 50 sas codes. in which %include (%include path/aaa.sas) statment should be added at the beginning of the sas code, for all 50 sas codes.
can I have a macro to Insert % include statment into the sas codes.
apprectite help!
Thanks.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend make NEW files with the changes. You can then QC the changes before replacing the OLD files with the new files.
Say the original files are in a directory named DIR1 and you have an empty directory named DIR2 where you can write the updated programs. And if you want to update ALL of the .sas file in DIR1 then you should be able to do it with a simple data step.
data _null_;
length fname1 fname2 $200 ;
infile 'c:\downloads\dir1\*.sas' filename=fname1;
input ;
fname2 = tranwrd(fname1,'c:\downloads\dir1\','c:\downloads\dir2\');
file out filevar=fname2;
if fname1 ne lag(fname1) then put '%include "path/aaa.sas";' ;
put _infile_;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you are asking for code to insert one line of code into existing SAS program files it is likely to be just as quick to open each and paste the text and save the file. With none of the possible problems of overwriting or accidentally modifying code. For one thing, you should make a back up of every single one of those file before starting or testing any such code just in case.
I would ask for a description of what that include code is supposed to do though. If that many different programs need it then perhaps there is a more robust way to use that file.
For example if the %include file contains only macro definitions then add the macro code that would be called to a location and add that location to the Autocall in your SAS Autoexec.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend make NEW files with the changes. You can then QC the changes before replacing the OLD files with the new files.
Say the original files are in a directory named DIR1 and you have an empty directory named DIR2 where you can write the updated programs. And if you want to update ALL of the .sas file in DIR1 then you should be able to do it with a simple data step.
data _null_;
length fname1 fname2 $200 ;
infile 'c:\downloads\dir1\*.sas' filename=fname1;
input ;
fname2 = tranwrd(fname1,'c:\downloads\dir1\','c:\downloads\dir2\');
file out filevar=fname2;
if fname1 ne lag(fname1) then put '%include "path/aaa.sas";' ;
put _infile_;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
it worked fine, Apreciate it.
need one more help in same way after adding '%include "path/aaa.sas";'
can we change 'USER="&userid" ORAPW="&pswd"' to "abcd=xyz" in same code
it makes job compete.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
need one more help in same way after adding '%include "path/aaa.sas";'
can we change 'USER="&userid" ORAPW="&pswd"' to "abcd=xyz" in same code
it makes job compete.
Thanks.