Help using Base SAS procedures

Spool Option and Include Statement

Reply
Contributor
Posts: 42

Spool Option and Include Statement

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
SAS Super FREQ
Posts: 8,740

Re: Spool Option and Include Statement

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
Respected Advisor
Posts: 3,777

Re: Spool Option and Include Statement

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.

[pre]
NOTE: This session is executing on the WIN_PRO platform.



NOTE: SAS 9.1.3 Service Pack 4

NOTE: SAS initialization used:
real time 0.25 seconds
cpu time 0.09 seconds

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

NOTE: There were 160 observations read from the data set SASHELP.CLNMSG.
WHERE LEVEL='N';
NOTE: The data set WORK.TEST has 160 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds


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: There were 160 observations read from the data set SASHELP.CLNMSG.
WHERE LEVEL='N';
NOTE: The data set WORK.TEST1 has 160 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


2 The SAS System 06:07 Thursday, September 10, 2009

1 OPTIONS SPOOL;
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
14 %list 1:20;
13
14 %list 1:20;

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 0.26 seconds
cpu time 0.10 seconds
[/pre]
Ask a Question
Discussion stats
  • 2 replies
  • 4574 views
  • 0 likes
  • 3 in conversation