BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JoeQcSas
Calcite | Level 5

 

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.

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

@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

7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

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

data_null__
Jade | Level 19

@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.
Haikuo
Onyx | Level 15

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.

data_null__
Jade | Level 19

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

 

Haikuo
Onyx | Level 15

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

data_null__
Jade | Level 19

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

Haikuo
Onyx | Level 15

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. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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