Exact same issues. But if I go to each of those two files and run them on their own, everything runs perfectly.
Doesn't your program file contain something like this:
data _null_;
file "R:\file_to_be_included.sas";
input;
put _infile_;
cards4;
proc print data=sashelp.iris(obs=1);
run;
%macro internal_macro();
%if 1=1 %then
%do;
data test1;
set sashelp.cars(obs=1);
run;
%end /* <== missing semicolon !!!!!!!!! HERE */
%mend internal_macro;
data test2;
set sashelp.class(obs=1);
run;
;;;;
run;
%macro choose_progs(which_progs);
%if &which_progs = set1
%then %do;
%include "R:\file_to_be_included.sas" / source2;
%end;
%else
%if &which_progs = set2 or
&which_progs = set3
%then %do;
%put THE OTHER CASE!;
%end;
%mend choose_progs;
%choose_progs(set1);
Bart
Are you just asking if the included files might be missing a semicolon or something? If so, then no, they are not. They run just fine on their own with no warnings or errors.
@TheEsotericPunk wrote:
Are you just asking if the included files might be missing a semicolon or something? If so, then no, they are not. They run just fine on their own with no warnings or errors.
One of the things that can occasionally make debugging in EG hard is that behind the scenes, in an effort to be helpful, after your code is submitted EG will add a magic string that will try to close any unmatched quotes for you.
In your original post you said that in a fresh EG session, if you run the code, you get "NOTE: Extraneous text on %END statement ignored." and the second file never even starts.
I assume that's a typo, and you mean %MEND statement?
I would start by fixing that. If there is an unmatched quote, that could explain both the extraneous text on the %mend statement (if SAS has ignored one of your %macro statements because it's hidden in an accidentally quoted string), and the second file "never starting."
The mantra of debugging in SAS is to start with the first error (or first note that should be thought of as an error).
OMG. I feel like a total idiot right now. It was a missing semi colon on one of the %end rows for part of the macro that was the unused part of the %IF. So I ran the code inside that and it runs fine but when I run the actual macro it fails.
As Art Carpenter said:
"SAS stands for: semicolon, always semicolon"
There are only 2 places you don't want to put a semicolon in SAS:
1) after the ELSE statement;
2) after calling a macro;
😉
Bart
And just to be clear, it's not that I'm so super smart to figure the root cause of your problem.
I've just went with @Kurt_Bremser's Maxims.
Maxim 6, to be precise: "Google is your friend."
This is the result of googling: "note: extraneous text on %end statement ignored."
Google provided only 2 links:
1) ia a thread where @Tom provides the answer,
and 2) is this very thread.
"All SAS questions were already answered" 😄
Bart
Here's what I would try:
Create 4 new mini programs:
\mypath\folder1\fake1.sas;
\mypath\folder1\fake2.sas;
\mypath\folder2\fake1.sas;
\mypath\folder2\fake2.sas;
All 4 of these programs can just be:
** folder1\fake1.sas ;
data folder1_fake1;
x=1;
run;
** folder1\fake2.sas ;
data folder1_fake2;
x=1;
run;
** folder2\fake1.sas ;
data folder2_fake1;
x=1;
run;
** folder2\fake2.sas ;
data folder2_fake2;
x=1;
run;
Literally save those as 4 distinct files.
Replace your 4 include statements so that they're instead pointing at the above, respectively.
Make sure the program runs OK like this.
If so, replace the first fake program with the first real one.
Retry.
Repeat until it fails.
Btw, avoid commenting out % statements with * -- this can lead to weird things, i.e.,
** instead of this: ;
*%include "some_program.sas";
** do one of these: ;
/* %include "some_program.sas"; */
* or, easier... ;
*include "some_program.sas";
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.