BookmarkSubscribeRSS Feed
Peter_C
Rhodochrosite | Level 12
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
6 REPLIES 6
art297
Opal | Level 21
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
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
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.
Peter_C
Rhodochrosite | Level 12
thank you Scott looks like windows scripting will solve my requirement. Would windows scripting allow me to generate the short config file?

peterC
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggested Google search argument for your follow-up question:

windows script host create file

Scott Barry
SBBWorks, Inc.
Peter_C
Rhodochrosite | Level 12
thank you Scott,
appreciate your calm brevity
I should not have needed to ask

Peter
Peter_C
Rhodochrosite | Level 12
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

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 1198 views
  • 0 likes
  • 3 in conversation