here are some tips about passing values into a sas session
For passing parameters into the start of a sas session, rather than
use sysparm, have a look at using environment variables.
These can be established in the environment before the sas session
is started, or can be established on the command that starts sas,
sas.exe -set plotfile "gplt123.jpg"
Once the sas session has started, pick up the value of environment
variables, either with
%let plotfile= %sysget(plotfile) ;
or in a data step that parses output from the set command, like:
filename evars pipe 'set ' lrecl= 5000 ;
data evars( compress= yes );
length name $40 value $5000 ;
infile evars length= len ;
input ; * just load buffer ;
if index( _infile_, '=' ) ; * evar definition needs an '=' ;
name = scan( _infile_, 1, '=' ) ;
** because the definition of an evar might include an
equals sign, this code avoids using
**value = scan( _infile_, 2, '=' ) ;
* just take the rest of the line, after the first '=';
value = substr( _infile_, index( _infile_, '=' )+1 ) ;
The data step has 2 particular merits
1 provides a complete collection of all evars
2 creates no warnings like %sysget() creates if the evar doesn't exist
By the nature of this code, you don't get the length of an evar, including
any trailing blanks that might be defined for it. As I see no need for
that (yet) I haven't added to the data step the line
evar_len = len - index( _infile_, '=' ) ;
To load these values into a regular process, the easiest way seems to be
proc sql noprint ;
select name, value
into :plotname1 - :plotname9999
, :plotfile1 - :plotfile9999
where name like 'plotfile%'
%let num_pltfiles = &sqlobs ;
You need a select statement for each range of evars you want to extract.
Alternatively, your data step could generate a macro var for every evar
with this statement
call symput( name, trim( value ) );
However, on unix beware that environment variables are case sensitive,
so evar "plotfile" and evar "Plotfile" can hold different values at
the same time, but sas macro variable names are not case sensitive
so only one of these values would be returned by &Plotfile and
I think you'll find the use of environment variables enables far
more solutions, than sysparm.
On Tue, 7 Jun 2005 19:44:04 -0700, chrysrobyn <chrysrobyn@GMAIL.COM> wrote:
>I'd like to generate a lot of plots, called from the command line. I'm
>taking &sysparm arguments pretty well for opening files, but I've
>hiccuped on putting out plots. My major problem is because gplot's
>name statement limits me to 8 characters (even on AIX), and my ideal
>&sysparm is 9 characters, with the leading 3 less important. SAS
>truncates the trailing character and ends up with non-unique filenames,
>which is an obvious problem. Simple enough, truncate the first 1-3
>%let LongName = &sysparm; /* For graphics limited to 8 characters */
>%let ShorterFileName = substr(&LotName,4,6);
>proc gplot data=sasdb.&sysparm._merged gout=graphs ;
> name = "&ShorterFileName";
>The problem is that when SAS hits gplot, SAS tries to write to a
>filename "substr(F" ("F" is the first character of &sysparm)-- and it
>correctly changes the "(" to a filesystem friendly character.
>I have used a data _null_ statement to attempt to verify my use of the
>substr function (and used "put" to log the desired substring), and no
>matter how many "put"s or "eval"s I put in the %let statement, gplot
>won't evaluate the variable before deciding the filename. The obvious
>answer is to remove the quotes, but SAS complains bitterly about their
>Looking through the archives, plenty of people have used variable names
>in the gplot name statements, but they have not required evaluation,
>they were only character strings assigned to variables for convenience.
>How can I get my substr evaluated before the let assignment is made?
>Thank you in advance for any tips.