DATA Step, Macro, Functions and more

config parameters

Reply
Valued Guide
Posts: 2,177

config parameters

in a sasv9.cfg file in "my documents\" I can provide sas system options that are my personal preference. Automatically this config file will be used when I invoke sas.exe without specifying any -config parameter.
I a config file SAS uses !prefix to indicate an environment variable, so
-WORK "!TEMP\SAS Temporary Files"
says assign system option WORK the path where-ever system environment variable TEMP points and under that in folder "SAS Temporary Files".
There are many of these environment variables used.

I would like to use an environment variable to name a file but behaviour is odd.
-altlog !PROG
uses the value in environment var PROG as the value for that system option, but
-altlog !PROG.log
create an altlog file named !PROG.log and does not substitute the value of the environment variable.

Is there a special symbol (like . following macro variable names) which does the job for environment variable reference in configuration files?
A "\" works and treats the environment variable as the name of a folder, but that is not what i want for the filename for the altlog.

hth
peterC
PROC Star
Posts: 7,467

Re: config parameters

Peter,

You are much more of an expert in this area than I am, thus I doubt if I can offer anything substantial.

I'm confused about what you are trying to do as, in your example, you show whatever.log, but isn't .log automatically assigned by -altlog?

Regardless, would %sysget() accomplish what you want to do?

Art
Super Contributor
Super Contributor
Posts: 3,174

Re: config parameters

Would it be unreasonable to assign the entire path-filename (file-extension included) as the environment variable?

Possibly, consider using Windows Script Host to launch SAS with specific command-line parameters, such as -SYSIN and -ALTLOG, or -SYSPARM or using INITSTMT= System Option.

Scott Barry
SBBWorks, Inc.
Valued Guide
Posts: 2,177

Re: config parameters

thank you Scott looks like windows scripting will solve my requirement. Would windows scripting allow me to generate the short config file?

peterC
Super Contributor
Super Contributor
Posts: 3,174

Re: config parameters

Suggested Google search argument for your follow-up question:

windows script host create file

Scott Barry
SBBWorks, Inc.
Valued Guide
Posts: 2,177

Re: config parameters

thank you Scott,
appreciate your calm brevity
I should not have needed to ask

Peter
Valued Guide
Posts: 2,177

Re: config parameters

Art297
thank you for the complement (appreciate it very much from you!)
Tried %sysget, but the resulting value is only the request for the env-var, not the value itself. Here are some notes pushed to SASlog to check on the situation [pre]
NOTE: local config file
C:\Users\Peter Crawford\Documents\my sas files\sasv9.cfg
contains
1 -set PROG demo.e-Vars
2 -awstitle %sysget(PROG)
3 -altlog %sysget(prog).log

environment variable PROG is demo.e-Vars
AWStitle has value %sysget(PROG)
altlog value is
C:\Users\Peter Crawford\Documents\my sas files\%sysget(prog).log[/pre]these messages were generated by this data step in autexec.sas
data _null_ ;
* collect and report testing of start-up parameters ;
length altlogv Var1-Var5 $1000 ;
altlogv = getoption( 'altlog' ) ;
Var1 = "%sysget( PROG )" ;
var2 = getoption( 'config' ) ;
var5 = getoption( 'awstitle' ) ;
put 'NOTE: ' ;
put 'NOTE: local config file ' @ ;
infile 'sasv9.cfg' filename= var3 end=eof ;
input @ ;
put var3 / @7 'contains';
do ROW=1 by 1 while( not eof );
input ;
var4 = _infile_ ;
PUT 'NOTE- ' row var4 ;
end ;
put 'NOTE- ';
option ls=70 ;
putLog 'NOTE- environment variable PROG is ' Var1 ;
putLog 'NOTE- AWStitle has value ' Var5 ;
putLog 'NOTE- altlog value is ' altLogV ;
putlog 'NOTE- config files used ' var2 ;
put 'NOTE- ';
put 'NOTE: ---------------------------------------------------' ;
stop ;
run ;

looks like I can only let an environment var be followed by a \
I hoped/wanted the env-var to work like a macro var, but it isn't achieving that.

peterC
Ask a Question
Discussion stats
  • 6 replies
  • 233 views
  • 0 likes
  • 3 in conversation