DATA Step, Macro, Functions and more

%Include

Accepted Solution Solved
Reply
Frequent Learner
Posts: 1
Accepted Solution

%Include

[ Edited ]

 

Hi!

 

Is it possible to use only a portion of the code call with %include in Z/OS.

 

For example, we have a SAS program containing 500 lines and we would like to include this program but wer'e only interested in the code between line 117 and 228.

 

Thank you.

 

 

 

 

 

 


Accepted Solutions
Solution
3 weeks ago
Respected Advisor
Posts: 3,846

Re: %Include


@JoeQcSas wrote:

 

Hi!

 

Is it possible to use only a portion of the code call with %include in Z/OS.

 

For example, we have a SAS program containing 500 lines and we would like to include this program but wer'e only interested in the code between line 117 and 228.

 

Thank you.

 

 

 

 

 

 


No but can use a tiny data step that you could make into a macro.

 

filename FT15F001 temp;
filename FT44F001 temp;
data _null_;
   infile FT15F001 firstobs=2 obs=3;
   file FT44F001;
   input;
   put _infile_;
   parmcards4;
*this is line 1;
*Line 2
line 3;
page;
;;;;

%inc FT44F001 / source2;

 

50   filename FT15F001 temp;
51   filename FT44F001 temp;
52   data _null_;
53      infile FT15F001 firstobs=2 obs=3;
54      file FT44F001;
55      input;
56      put _infile_;
57      parmcards4;
62   ;;;;

NOTE: The infile FT15F001 is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: The file FT44F001 is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: 2 records were read from the infile (system-specific pathname).
      The minimum record length was 7.
      The maximum record length was 7.
NOTE: 2 records were written to the file (system-specific pathname).
      The minimum record length was 7.
      The maximum record length was 7.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


63
64   %inc FT44F001 / source2;
NOTE: %INCLUDE (level 1) file FT44F001 is (system-specific pathname).
65  +*Line 2
66  +line 3;
NOTE: %INCLUDE (level 1) ending.

View solution in original post


All Replies
PROC Star
Posts: 1,215

Re: %Include

No. As the SAS Documentation states: 

 

Restriction You cannot selectively include lines from an external file.

 

You can however include lines selectively that were previously entered in the same SAS program

Solution
3 weeks ago
Respected Advisor
Posts: 3,846

Re: %Include


@JoeQcSas wrote:

 

Hi!

 

Is it possible to use only a portion of the code call with %include in Z/OS.

 

For example, we have a SAS program containing 500 lines and we would like to include this program but wer'e only interested in the code between line 117 and 228.

 

Thank you.

 

 

 

 

 

 


No but can use a tiny data step that you could make into a macro.

 

filename FT15F001 temp;
filename FT44F001 temp;
data _null_;
   infile FT15F001 firstobs=2 obs=3;
   file FT44F001;
   input;
   put _infile_;
   parmcards4;
*this is line 1;
*Line 2
line 3;
page;
;;;;

%inc FT44F001 / source2;

 

50   filename FT15F001 temp;
51   filename FT44F001 temp;
52   data _null_;
53      infile FT15F001 firstobs=2 obs=3;
54      file FT44F001;
55      input;
56      put _infile_;
57      parmcards4;
62   ;;;;

NOTE: The infile FT15F001 is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: The file FT44F001 is:
      (system-specific pathname),
      (system-specific file attributes)

NOTE: 2 records were read from the infile (system-specific pathname).
      The minimum record length was 7.
      The maximum record length was 7.
NOTE: 2 records were written to the file (system-specific pathname).
      The minimum record length was 7.
      The maximum record length was 7.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


63
64   %inc FT44F001 / source2;
NOTE: %INCLUDE (level 1) file FT44F001 is (system-specific pathname).
65  +*Line 2
66  +line 3;
NOTE: %INCLUDE (level 1) ending.
Respected Advisor
Posts: 3,167

Re: %Include

[ Edited ]
Posted in reply to data_null__

I always couldn't get it, why SAS has to pair "parmcards4" with an obscure device name such as "FT15F001"? It would be nice if SAS can remove this kind of restriction, so programmers don't have to remember or  look it up in docs of version 8 and just come up some generic names they like.

Respected Advisor
Posts: 3,846

Re: %Include

[ Edited ]

@Haikuo wrote:

I always couldn't get it, why SAS has to pair "parmcards4" with an obscure device name such as "FT15F001"? It would be nice if SAS can remove this kind of restriction, so programmers don't have to remember or  look it up in docs of version 8 and just come up some generic names they like.


Hi @Haikuo

 

The name FT15F001 is the default and can be changed.  The file does not have to be temporary.

 

Back when there was only mainframe FT11F001 and FT12F001 were LOG and LST respectively.  I can't remember if there were other unit numbers used. 

 

PARMCARDS is fully documented in the most current SAS documentation.  This excerpt is in reference to the SAS system option PARMCARDS.

 


Syntax 


PARMCARDS=file-ref



Syntax Description 


file-ref


specifies the file reference to open. 


Details 


The PARMCARDS= system option specifies the file reference of a file that SAS opens when it encounters a PARMCARDS (or PARMCARDS4) statement in a procedure. 

SAS writes all data lines after the PARMCARDS (or PARMCARDS4) statement to the file until it encounters a delimiter line of either one or four semicolons. The file is then closed and made available to the procedure to read. There is no parsing or macro expansion of the data lines. 

 

Respected Advisor
Posts: 3,167

Re: %Include

Posted in reply to data_null__

Thank you for the explanation. I will let others be aware of the system option.

Respected Advisor
Posts: 3,846

Re: %Include

[ Edited ]

@Haikuo wrote:

I will let others be aware of the system option.


Do you use PARMCARDS often?  I don't and thought I was the only one who uses it ever.  (but I never say ever -Smiley Happy

Respected Advisor
Posts: 3,167

Re: %Include

Posted in reply to data_null__

We do, John. We do SAS tutorials/presentations for clients, and this comes in handy in terms of simulating input files (stream) with their contents exposed the same screen. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 173 views
  • 2 likes
  • 4 in conversation