![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS Companion for the CMS Environment |
SAS supports inline comments as an extension of the standard CMS pipeline interface, as shown:
filename adata pipe '(name adata) /* name pipeline */ < archive data a /* read in file */ | unpack /* unpack */ ';
filename adata pipe '(name adata) /* name pipeline */ < archive data a /* read in file */ | unpack /* unpack */ | fitting sasio /* added by SAS */ ';
filename twostrm pipe '(endchar %) < jan data a | a: fanin | fitting sasio % < feb data a | a: ';
/* UNPKDATA REXX */ parse arg fileid 'callpipe <' fileid, '| unpack', '| *:' exit
Then you could write your FILENAME statement as
filename mydata pipe
'(name mydata) /* name pipeline */
rexx unpkdata archive data a
/* read and unpack a file */
';
Macro variables are resolved within a pipeline specification that is enclosed in double quotes.
/* Data step to get spoolid. Only accept files */
/* sent by a specified userid */
data _NULL_;
infile /* define the pipeline */
'cp query rdr /* query all rdr files */
|strfind /USERABC / /* from this userid only */
|take 1 /* only process one file */
|specs word 2 1' /* keep only the spoolid */
PIPE;
input spid $; /* read spoolid as char variable */
/* save spoolid as macro variable */
call symput('SPOOLID',spid);
run;
/* define fileref for reading netdata rdr file */
filename nd pipe
"reader file &spoolid /* read the file */
|drop 1 /* skip TAG */
|specs 2-* 1 /* skip CC byte */
|deblock netdata /* interpret netdata format */
|strfind xC0 /* keep only data records */
|specs 2-* 1 /* skip control byte */
";
/* datastep to read input from rdr file */
/* write data to USERABC DATA in packed format */
data abc;
file /* pipe for PUT processing */
' strip /* strip blanks */
| pack V 80 /* write packed format */
| > userabc data a fixed' pipe; /* this file */
infile nd; /* read from ND fileref */
input x; /* read var x from each rec */
put x; /* write to USERABC DATA in packed format */
run;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.