July 2005 Technical Tip - SAS: Passing parm data from JCL to SAS
If you want to make truly robust SAS programs, you’ll need to master the use of macro variables. And if those SAS programs are being run in a mainframe environment, you’ll want to be able to initialize those variables from your JCL rather than by modifying the SAS source code. This article will show you how to pass parm data from JCL to SAS. This is cool stuff!
In the following program I initialize two JCL symbolic parameters: GREETING is 'HELLO SAS' and NUMBER is 123.45. I then reference those parameters in the EXEC card as PARM='SYSPARM="&GREETING,&NUMBER"'. Note that the PARM value is enclosed in apostrophes whereas the SYSPARM value is enclosed in quotes! This is critical!
I wrote a data step to parse the parm. I have sacrificed conciseness here for readability. Recall that DATA _NULL_ indicates that a SAS dataset is not being created. My parm is comma separated so I use the INDEX function to locate the comma and the SUBSTR function to parse the fields. I then use CALL SYMPUT to create two new macro variables. SAS macro variables are always treated as text; nevertheless, they can be used to assign a value to numeric variable. Sample assignments might include:
The output of interest from this SAS program is in the log:
Want to know more about SAS? Give us a call! Mainframe or PC, you can count on Caliber Data Training for top quality education.