BookmarkSubscribeRSS Feed
Pramod_R
Calcite | Level 5
Hi,

I wanted to know if we could pass parameters to the SAS program which we use in %include statement using the sysparm option.

If so.. Could you please tell me how do we do it?

Thanks in advance.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Set a SAS macro variable (using a %LET statement) and use that macro variable in your included program. You may also need/want to use a %GLOBAL statement from within your included program, if it does not always expect the macro variable to be set to some non-blank value.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

pass parameters to program site:sas.com

global macro variables site:sas.com
Peter_C
Rhodochrosite | Level 12
> Hi,
>
> I wanted to know if we could pass parameters to the
> SAS program which we use in %include statement using
> the sysparm option.
>
> If so.. Could you please tell me how do we do it?
>
> Thanks in advance.

-sysparm
is loaded as SAS starts
On win and unix platforms (but not on z/OS, iirc ) you can establish additional parameters in the invocation line
"path/sas.exe" -sysin your.prog.sas -set extra "additional_code.sas" -sysparm "what ever"
within your main program (named your.prog.sas above) you would add
%include !extra /source2 ;
then program "additional_code.sas" would be included.
Of course you could add it to the sysparm string, but then you will need to parse it out of that string if you use the sysparm for any other purpose.
When running on zOS you would need to provide the value in sysparm as sas is invoked. Your local methods for starting sas on z/OS may (normall) be different, so ask other sas programmers or an administrator.
Once SAS has started &sysparm is like any other macro variable, so expect to use %substr() or %scan() to extract the program name, into macro variable (for example) extra. Then just
%include "&extra" /source2 ;
If the additional program is the only thing in sysparm, then no scan or substr is needed, just
%include "&sysparm" /source2 ;

I'm recommending the /source2 option for the %include because it not only shows the lines of code included, but also shows the full external path and file name, which I find reassuring!

peterC

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 3295 views
  • 1 like
  • 3 in conversation