DATA Step, Macro, Functions and more

Implement altlog in the code

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

Implement altlog in the code

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


Accepted Solutions
Solution
‎08-22-2014 07:32 AM
Valued Guide
Posts: 2,174

Re: Implement altlog in the code

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


All Replies
Valued Guide
Posts: 2,174

Re: Implement altlog in the code

See options XWAIT

Valued Guide
Posts: 3,208

Re: Implement altlog in the code

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 --<-----
Contributor
Posts: 68

Re: Implement altlog in the code

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?

Valued Guide
Posts: 3,208

Re: Implement altlog in the code

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 --<-----
Contributor
Posts: 68

Re: Implement altlog in the code

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

Solution
‎08-22-2014 07:32 AM
Valued Guide
Posts: 2,174

Re: Implement altlog in the code

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

Contributor
Posts: 68

Re: Implement altlog in the code

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

Valued Guide
Posts: 2,174

Re: Implement altlog in the code

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 =)

Valued Guide
Posts: 3,208

Re: Implement altlog in the code

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 --<-----
Super User
Posts: 10,483

Re: Implement altlog in the code

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.

Contributor
Posts: 68

Re: Implement altlog in the code

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

Valued Guide
Posts: 3,208

Re: Implement altlog in the code

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

---->-- ja karman --<-----
Contributor
Posts: 68

Re: Implement altlog in the code

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

Valued Guide
Posts: 2,174

Re: Implement altlog in the code

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 21 replies
  • 848 views
  • 12 likes
  • 5 in conversation