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.
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.
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.
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.
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:
That could help identify which file is problematic.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.