BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Krysia24
Obsidian | Level 7

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

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.

Krysia24
Obsidian | Level 7

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. 

Quentin
Super User

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:

  1. Make four separate files file1.sas with just the code %put file1.sas running; and similar for file2.sas file3.sas file4.sas.
  2. 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.
  3. 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.
  4. 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.

 

 

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Krysia24
Obsidian | Level 7
Thank you! It did end up being a sneaky comment that I didn't see at first.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1181 views
  • 5 likes
  • 3 in conversation