BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SergioSanchez
Calcite | Level 5

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 Smiley Sad

Please any help

Regards

1 ACCEPTED SOLUTION

Accepted Solutions
Peter_C
Rhodochrosite | Level 12

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

View solution in original post

21 REPLIES 21
Peter_C
Rhodochrosite | Level 12

See options XWAIT

jakarman
Barite | Level 11

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.

---->-- ja karman --<-----
SergioSanchez
Calcite | Level 5

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?

jakarman
Barite | Level 11

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\    

---->-- ja karman --<-----
SergioSanchez
Calcite | Level 5

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?.

Peter_C
Rhodochrosite | Level 12

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

SergioSanchez
Calcite | Level 5

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

Peter_C
Rhodochrosite | Level 12

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 😃

jakarman
Barite | Level 11

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 )   

---->-- ja karman --<-----
ballardw
Super User

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.

SergioSanchez
Calcite | Level 5

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

jakarman
Barite | Level 11

Did you start sas wihtoud mentioning the sas-program but with all those altlog settings?

---->-- ja karman --<-----
SergioSanchez
Calcite | Level 5

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

Peter_C
Rhodochrosite | Level 12

For an interactive session just remove the -sysin option and change the -log to -altlog

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 21 replies
  • 6685 views
  • 15 likes
  • 5 in conversation