How to open and close the Log window via code? - sas

My Log window seems happend some font cahe issue, Sometimes it suddenly makes the font BOLD and that bothered me these days. Here is my first question: Dose anybody has any hints about the font issue?
Forunately I find the Log window return to normal if only I close and reopen it, so here comes my
second question: Is it possible to open and close the Log window in SAS DMS? If so, how to write it?

Use the DM statement to programmatically submit available SAS Commands under Windows or SAS Display Manager Windows Window Commands and most important for this question SAS Windows and Access Methods
The LOG command has a seemingly undocumented (online web docs) option OFF. There is likewise a seemingly undocumented command CLEAR. These commands are documented in Windows DM via F1 (Help) -- do a Quick Search for "SAS Windows and Access Methods".
DM 'CLEAR LOG; LOG OFF' LOG;
You might also want to check the DM windows font setting. Submit or issue DLGFONT
DM `DLGFONT`;
Finally, worst case, there is a possibility the SAS DM configuration file is damaged. Locate regstry.sas7bitm, profile.sas7bcat in the sasuser operating system folder and , when SAS is closed, rename them so they are recreated anew at the next DM SAS session start.
If you are using a different SAS client, update your question and add your system setup.

Related

How to print SAS program log to console when running in batch mode

I am running my SAS program in batch mode through windows command prompt.
Start /WAIT "SAS_job" "C:\Program Files\SASHome\SASFoundation\9.4\sas.exe" -sysin D:\MySAS_Test.sas -nosplash -nologo -noicon
Can I display the SAS output or log on command prompt instead of writing to a file? Or print log as SAS program is running to track progress.
I think this is possible in Unix, but I'm not so sure about Windows.
You can write to STDOUT in Unix as mentioned in the documentation. But I don't see any such similar thing in Windows.
The most similar thing is unnamed pipes, which lets you interact with the console - but it's unclear if this is potentially helpful for you or not.
Unfortunately, I suspect SAS is generally not considering Windows a server type environment, and mostly supporting it to allow for desktop use; while it does support Windows servers certainly, most SAS server usage is Linux/Unix.
Your better bet is probably to go in the direction of another program that reads from the log file already produced and writes it out to the console, something analagous to tail in Unix. Or as mentioned in comments open the log in a text editor (you can even 'push' this from SAS if you have option xcmd enabled) and let it auto-refresh periodically.
One common use case in fact is to use, for example, UltraEdit to edit your SAS programs; it can even run them in batch directly, and then retrieve the log in that program.

SAS Error Handling in Windows Batch

I have a scheduled SAS program in Windows, e.g.
sas.exe -nosplash -icon -sysin "myprogram.sas"
This process will hang if there's an "Out of Resources" error (e.g. no disk space), prompting for user input (Retry, Cancel, etc.). As it's a batch job, there is no user to give that input.
Is there a SAS system option which prevents the prompt for user input so it can be dealt with in the code itself?
How about -noterminal?
Extract from documentation:
If NOTERMINAL is specified, dialog boxes are not displayed.
Trying using the option
-batch
Since you are running in batch mode, also consider using the option
-errorabend
The best option is
-get_more_resources ;)
If the program is the cause to the resource error you have another question to ask!

Autoit controlsend remote desktop

I have a remote desktop and i'm trying to run a simple script to prevent idle session timeout, which is 3 min (quite annoying). The script should, for example, press "A" key every 2.5 min or so.
Problem is, the remote desktop window is often inactive/minimized and:
1) if i try to run such a script "inside" the remote desktop, i still get disconnected, despite it actually works (continues to type or create/delete files etc even as the "idle timer expired" message is on screen). i believe the system wants some "external" action.
2) if i run the script on my PC, it doesn'do anything at all on the remote desktop (i had an open notebook there, and there was no typing):
ControlSend("[CLASS:TscShellContainerClass]", "", "[CLASS:OPContainerClass; INSTANCE:1]", "{A}")
I think the problem lies with the "controlid" part, which i got via autoit window info. If i set controlid as "" - it works, but only if the window is currently active.
I've seen a registry key solution, but doesn't seem to work for me.
If anyone has any ideas about fixing this, please, don't hold back:)
I know it's late but here's the ONLY thing I could get to work; it involved activating the window. I tried ControlFocus but to no avail, so here's what I got.
You should be able to modify your script as needed.
#include<Array.au3>
OPT("WinTitleMatchMode",2)
$a = WinList("Remote Desktop Connection")
;_ArrayDisplay($A)
ConsoleWrite(UBound($A)& #CRLF)
FOR $N = 1 to $A[0][0]
$hActiveWindow = WinGetHandle("")
WinActivate($a[$N][1]) ;comment if using controlfocus
;ControlFocus($a[$N][1],"","") ;comment if using winactivate
ControlSend($a[$N][1],"","","^+{ESC}")
WinActivate($hActiveWindow)
Next

Open SAS program in new instance

I'm trying to figure out a way to open SAS programs in new instances of the Enhanced Editor by default on click.
The question has been asked before but no luck.
This paper describes the way a program is opened with the Enhanced Editor. The full command is :
"C:\PROGRA~1\SASHome\SASFOU~1\9.3\core\sasexe\SASOACT.EXE" action=Open
datatype=SASFile filename="%1" progid=SAS.Application.903
The author explains that:
The sasoact.exe program is used to launch an OLE automation session of SAS.
Automation
is a mechanism through
which one Windows application can control another application programmatically. When you double-click a SAS file
type, sasoact.exe checks to see if an existing OLE automation session of SAS is running. If not, it then invokes an
OLE automation session of SAS. Once there is an active
SAS automation server session, any further calls from
sasoact.exe are handled by the existing SAS session instead of in a new
SAS session.
I guess having only one OLE session is usefull in some way or another but it's really annoying when you have to manually open a new EE instance every time you want to run multiple jobs. Not to mention that sasoact targets the first session initiated and if a job is already running on that session well your program is not going to open.
Is there a way to directly request a new instance of the OLE session or perhaps "trick" sasoact.exe into not seeing the opened sessions ?
[EDIT] Well too bad it's been closed as duplicate because the answer is substantially different than the other question's. Also it might help others who do not want to run their programs from a batch file.
Here is the registry key that works:
"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -initstmt "dm 'whost;include ''%1'' ';"
I added it in HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command so now I have a neat little extra option in my drop-down menu that effectively opens programs in new sessions on click:
A similar thread showing the use of a batch file to open a SAS program in a new session is available here.
If you want to open a .sas program in a new session by simply clicking the program here is how to do it:
You have to add an entry to the registry. Be careful when messing around with registry files, always back up your entries.
Open the registry editor (WIN+R > regedit).
In the directory HKEY_CLASSES_ROOT\SAS.Program.701\shell\ create a sub-directory with a meaningful name(right-click on shell > New > Key). I named mine "Open New". In this new sub-directory create another sub named command. You should now have a path that looks like:
HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command
In here, right-click on the file on the registry file on the right > Modify and add the following in the Value data field (change the path of sas.exe if needed)
"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -NOTUTORIALDLG -initstmt "dm 'whost;include ''%1'' ';"
Close the editor. You should now have the new option specified in the drop-down menu of the right-click on a .sas program:
This option will open your program with the Enhanced Editor in a new SAS session.
Now if you want it to work for double-clicking I suppose you'd have to replace the value in the Open sub-directory with the one from above. I haven't done it and I don't recommend it, the extra option in the drop-down is enough for me.

ctrl+e doesn't clear output window but exits SAS program?

when i tried to clear the output window using ctrl+e, it terminated SAS. My SAS version is 9.3M2. Has anyone encountered the same problem? Thanks.
Looks like there is a hot fix for this. It is supposed to be fixed in 9.3TSM2, so if it is not you may need to contact SAS support.
The kb article with the hot fix is located currently here (kb# 45003).
While not exactly what you are asking, we hot-key the clearing of the log and output so someone doesn't accidentally CTRL-E their program window.
Type keys in the command box
Type output;clear;log;clear;wpgm into the command for a key (we use F12)
This will clear the log and output windows and bring the current program editor to focus.