- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello! I have a program that begins by bringing in four separate SAS programs using %INCLUDE {all separate import programs - bringing in data} and then is followed by some proc sql steps. So it looks like this:
%INCLUDE 'filepathprogram1' ;
%INCLUDE 'filepathprogram2' ;
%INCLUDE 'filepathprogram3' ;
%INCLUDE 'filepathprogram4' ;
proc sql;
create table {using the data from the above files....}
etc.
______________________________________________
When I run the program as a whole, only the first two include statements run and then SAS skips filepath programs 3 and 4, and just moves onto the proc sql step {which won't work because it hasn't brought in all the data needed from filepaths 3 and 4}. However, if I run this line by line (so if I run include statement 1, then 2, then 3, then 4), then the rest of the program works fine.
Is there a reason for this? Is there a limit to how many include statements I run at once? I thought they ran sequentially so it would not matter? Any more information to help me debug this would be helpful.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Look into your included files. I suspect program2 has a comment at the end without the closing */, or unbalanced quotes.
When you run them one by one, the "magic statement string" sent by your client (Studio or Enterprise Guide) after the code often manages to clean this up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Look into your included files. I suspect program2 has a comment at the end without the closing */, or unbalanced quotes.
When you run them one by one, the "magic statement string" sent by your client (Studio or Enterprise Guide) after the code often manages to clean this up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So far I'm not noticing anything obvious but I'll keep looking through those codes. I should note I made a mistake when I wrote the original post: SAS runs filepaths 1 and 3 and skips over 2 and 4.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This approach should work fine.
If you set options NOSOURCE2 and then run the whole program, what does the log show for the four %include statements? Can you post the log?
I like Kurt's guess that it's likely a problem in one of the %include files.
You could always try brute force:
- Make four separate files file1.sas with just the code %put file1.sas running; and similar for file2.sas file3.sas file4.sas.
- Make a driver program that %includes all four files, in sequence just like your real program. Run the driver program and get it to work and print the four %PUT statements to the log.
- Change the first %include from %including file1.sas to %include your real first file. Re-run the driver and make sure all four %includes still work.
- Then continue add your real files one at a time and testing after each, until it breaks.
That could help identify which file is problematic.
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content