Morning all
I need a copy of the code log so I try to use altlog in my program but I afraid I don´t know how to achieve with success and the web pages I found don't explain very well
I want to safe a copy of the log in for example C:\Users\dummytest\Desktop\Sergio.
For this I write at the beggining of my code
proc options define value option = altlog;
dm 'MyProgram' -altlog C:\Users\dummytest\Desktop\Sergio\;
but nohing happens. Its seems easy but I am unable to accomplish the task
Please any help
Regards
Make a folder just for this test
For example
C:\test\bat1\
In that folder create the file
sasv9.cfg
In that file put the lines
-sysin "path and name of program you want to run"
-logparm rollover=session
-log "path and name.at.#y-#m-#d.log"
Just for this test, create a desktop icon
name test my batch sas
command {path to sas.exe]\sas.exe
startin folder c:\test\bat1
The command needs no more than the path and name of sas.exe
(depending on the path, it might need to be protected with double quotes)
Then launching the icon you have created will launch your program in batch
and wirh the logfile you named in the sasv9.cfg file but with # items replaced with year month and day
There are more # features including time parts and processID. They are documented for the LOGPARM option (which you have to change from default value rollover=none)
If you don't want to test with that icon you could create a windows script or dos batfile...... as long as you set the start-in folder to the one holding that sasv9.cfg file
There is a paper on this in the 2013 SAS Global Forum. The title is something about launching SAS with less risk
See options XWAIT
Check the altlog option SAS(R) 9.4 Companion for Windows, Third Edition it can only be set at invocation time. Not in a running sas session.
When needing that change the config.sas or the way you start sas (scritp/cmd) and give the option there.
Could you please make an example for me?
How can I start sas from script or cmd command.
Sorry for such a questions but its very important for me.
Thanks a lot in advanced.
pd: I have SAS 9.1.3, is there a problem for altlog option?
Having SAS 9.1.3 is no problem, the altlog option is a very old one. Cannot remember it was not there.
You are starting sas is some way... clicking on icon or whatever.
Behind the icon the cmd for starting sas is hidden. You can make a copy (short-cut and change that.
Perhaps more easy is to find the config.sas file of your installation. C:/program files/SAS ..... or do proc options is a running sas session an search for the names
This syntax looks all right. -altlog C:\Users\dummytest\Desktop\Sergio\
I have had success doing a shortcut to the sas.exe and edit the line
"C:\Program Files\SAS\SAS 9.1\sas.exe" -altlog -altlog C:\Users\dummytest\Desktop\Sergio\test.log
Now, is there any option to change the name of the log dinamically or this is the best I can do?.
Make a folder just for this test
For example
C:\test\bat1\
In that folder create the file
sasv9.cfg
In that file put the lines
-sysin "path and name of program you want to run"
-logparm rollover=session
-log "path and name.at.#y-#m-#d.log"
Just for this test, create a desktop icon
name test my batch sas
command {path to sas.exe]\sas.exe
startin folder c:\test\bat1
The command needs no more than the path and name of sas.exe
(depending on the path, it might need to be protected with double quotes)
Then launching the icon you have created will launch your program in batch
and wirh the logfile you named in the sasv9.cfg file but with # items replaced with year month and day
There are more # features including time parts and processID. They are documented for the LOGPARM option (which you have to change from default value rollover=none)
If you don't want to test with that icon you could create a windows script or dos batfile...... as long as you set the start-in folder to the one holding that sasv9.cfg file
There is a paper on this in the 2013 SAS Global Forum. The title is something about launching SAS with less risk
Thanks Peter
I get the following error
ERROR: Unrecognized SAS option name, SESSION
ERROR: Unrecognized SAS option name, =
ERROR: (SASXKRIN): KERNEL RESOURCE INITIALIZATION FAILED.
UNABLE TO INITIALIZE THE SAS KERNEL
my sasv9 file is like this
-awsTitle mySAS
-verbose
-SYSIN "C:\Program Files\SAS\SAS 9.1\sas.exe"
-LOG "C:\Users\dddd\Desktop\sas\testcfg\log.#y-#m-#d.log"
-logparm rollover=session
The value for the -sysin option should be the path and name of a .sas program
e.g.
c:\test\myQTest.sas
checking the online doc (you should too) the logparm option value their example appears in double quotes (probably because of that 😃
You can put in an environment variable. When you have command prompt running yougan give a "set" command to see them. TMP TEMP and USERname are common available.
"C:\Program Files\SAS\SAS 9.1\sas.exe" -altlog -altlog %TMP%\%USERNAME%\altlog.log Should work when Windows does the variable expansion.
I am not sure whether it works with altlog 9.1.3 and Windows but there are parameters possible at the logfile. #d #h to find them
SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition ( Directives for Controlling the Name of SAS Log Files )
Instead of altlog you may want to investigate Proc Printto with log= option . That would allow start/stop of the log output and changing file names in mid session/program.
I got it, the issue was -logparm rollover=session, the write option is -logparm "rollover=session".
Thanks Peter for your help but I confused because I thought I´d have two copies of the log, the one is showed in the sas window and the second the copy I told SAS to save to a specific Path.
However I only see a window where I can see the path than the log and lst will save. I believed that a window opened and the code run as if a macro was.
Sorry for the questions but is there any option for write the code in a window. Its my first time I run a program in batch way.
Ballardw, if I not wrong with proc printto you only get the log from a file or by OSD, I need the two ways, see the code in the window an make a copy in the file system.
Thanks for your help
Did you start sas wihtoud mentioning the sas-program but with all those altlog settings?
Hi Jaap
I followed the Peter's steps and my SASV9.CFG looks like this
-awsTitle mySAS
-LOG "C:\Users\myuser\Desktop\Sergio\testcfg\SASLOG_#Y#m#d_#H#M.LOG"
-sysin "C:\my path route\my program.sas"
-logparm "rollover=session"
Regards
For an interactive session just remove the -sysin option and change the -log to -altlog
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: