BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Scottcom4
Calcite | Level 5
Good Afternoon,

I have recently stumbled over using the Spool Option in tandem with the Include statement which would assist in reducing the amount of code I have. An example of what I have is below.

OPTIONS SPOOL;

DATA TEST;
SET SASHELP.CLNMSG;
WHERE LEVEL = "N";
RUN;

DATA TEST1;
%INC 4:5;
RUN;

It appears very simpe, but I get nothing in dataset TEST1.

Does anyone have an idea about what I am doing wrong? I have trawled the internet, but can't find anything of use.

Your help is greatly appreciated.

Regards,
Scott
1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

Run your program in BATCH. It appears that %INC line numbers is not supported in Windows DMS where I tested it. As I recall INCing line number ranges was originally for interactive line mode SAS sessions, where it is a sort of poor mans recall.

It also appears that interactive line mode is not supported in windows os.

Example with %INC using line numbers.

1          OPTIONS SPOOL=1 GENERIC=1 STIMER=0;
2          
3          DATA TEST;
4             SET SASHELP.CLNMSG;
5             WHERE LEVEL = "N";
6             RUN;

NOTE: The data set WORK.TEST has 160 observations and 6 variables.

7          
8          DATA TEST1;
9             %inc 4:5 / source2;
NOTE: %INCLUDE (level 1) previous line numbers.
10        +   SET SASHELP.CLNMSG;
11        +   WHERE LEVEL = "N";
NOTE: %INCLUDE (level 1) ending.
12            run;

NOTE: The data set WORK.TEST1 has 160 observations and 6 variables.


%LIST example to show lines submitted 1-13 the listed lines appear before the %LIST statement that produces the output.

  1 OPTIONS SPOOL=1 GENERIC=1 STIMER=0;
  2 
  3 DATA TEST;
  4    SET SASHELP.CLNMSG;
  5    WHERE LEVEL = "N";
  6    RUN;
  7 
  8 DATA TEST1;
  9    %inc 4:5 / source2;
  10    SET SASHELP.CLNMSG;
  11    WHERE LEVEL = "N";
  12    run;
  13 
13         
14         
15         %list 1-13; 

 

 

View solution in original post

2 REPLIES 2
Cynthia_sas
Diamond | Level 26
Hi:
Here's the doc:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a000218370.htm

The difference between your example and the example in the doc is that they do not show the included code from one data step program inside a second (different) data step program. You might wish to work with Tech Support on this question.

cynthia
data_null__
Jade | Level 19

Run your program in BATCH. It appears that %INC line numbers is not supported in Windows DMS where I tested it. As I recall INCing line number ranges was originally for interactive line mode SAS sessions, where it is a sort of poor mans recall.

It also appears that interactive line mode is not supported in windows os.

Example with %INC using line numbers.

1          OPTIONS SPOOL=1 GENERIC=1 STIMER=0;
2          
3          DATA TEST;
4             SET SASHELP.CLNMSG;
5             WHERE LEVEL = "N";
6             RUN;

NOTE: The data set WORK.TEST has 160 observations and 6 variables.

7          
8          DATA TEST1;
9             %inc 4:5 / source2;
NOTE: %INCLUDE (level 1) previous line numbers.
10        +   SET SASHELP.CLNMSG;
11        +   WHERE LEVEL = "N";
NOTE: %INCLUDE (level 1) ending.
12            run;

NOTE: The data set WORK.TEST1 has 160 observations and 6 variables.


%LIST example to show lines submitted 1-13 the listed lines appear before the %LIST statement that produces the output.

  1 OPTIONS SPOOL=1 GENERIC=1 STIMER=0;
  2 
  3 DATA TEST;
  4    SET SASHELP.CLNMSG;
  5    WHERE LEVEL = "N";
  6    RUN;
  7 
  8 DATA TEST1;
  9    %inc 4:5 / source2;
  10    SET SASHELP.CLNMSG;
  11    WHERE LEVEL = "N";
  12    run;
  13 
13         
14         
15         %list 1-13; 

 

 

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand in the Innovate Hub.

Watch Now →
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 19793 views
  • 0 likes
  • 3 in conversation