BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
TheEsotericPunk
Fluorite | Level 6

Exact same issues. But if I go to each of those two files and run them on their own, everything runs perfectly.

yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



TheEsotericPunk
Fluorite | Level 6

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.

Quentin
Super User

@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).

The Boston Area SAS Users Group (BASUG) is hosting an in person Meeting & Training on June 27!
Full details and registration info at https://www.basug.org/events.
TheEsotericPunk
Fluorite | Level 6

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. 

yabwon
Onyx | Level 15

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

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."

yabwon_0-1744193009373.png

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

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



quickbluefish
Barite | Level 11

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";

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 22 replies
  • 1833 views
  • 13 likes
  • 10 in conversation
OSZAR »