BookmarkSubscribeRSS Feed
ScottBass
Rhodochrosite | Level 12

@ChrisHemedinger 

 

tl;dr: 

Before I reinvent the wheel, has anyone created an EG custom task that plays a sound on the local machine (where EG is running)?

 

Details:

If you Google "SAS Enterprise Guide play sound when program finishes", you'll see this has been requested often.  Perhaps one day it will make it into the product.  (I'm running EG 7.15).

 

Note this handy little option in SQL Server Management Studio:

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

2020-04-01_17-26-05.jpg

 
 
 
 
 

I got this working today but the approach is klunky.  With little explanation:

 

* two examples ;
filename cmd pipe "\\UNC\path\to\PsExec\reachable\from\SASApp\Server\SysinternalsSuite\PsExec.exe -i \\MYLOCALMACHINE powershell.exe -command ""& {[system.console]::Beep(1000,3000)}"" ";
filename cmd pipe "\\UNC\path\to\PsExec\reachable\from\SASApp\Server\SysinternalsSuite\PsExec.exe -i \\MYLOCALMACHINE powershell.exe -command ""& {([System.Media.SystemSounds]::Asterisk).Play()}"" ";
data _null_;
   infile cmd;
   input;
*   putlog _infile_;
run;

* Or... ;
%let cmd=\\UNC\path\to\PsExec\reachable\from\SASApp\Server\SysinternalsSuite\PsExec.exe -i \\MYLOCALMACHINE powershell.exe -command ""& {([System.Media.SystemSounds]::Asterisk).Play()}"" ;
%let cmd=\\UNC\path\to\PsExec\reachable\from\SASApp\Server\SysinternalsSuite\PsExec.exe -i \\MYLOCALMACHINE powershell.exe -command ""& {([System.Media.SystemSounds]::Beep).Play()}"" ;
systask command "&cmd" wait cleanup;

 

 

But there are all sorts of reasons why this might not work in your environment:  requires Enable-PSRemote in Powershell, requires Windows Remote Management (WS-Management) service to be running on your local machine, requires ALLOWXCMD, requires a Windows SAS server, etc.

 

It occurred to me that if I had a simple EG custom task that played a sound (and the above is a good head start), I could just drop that task into my process flow and link it to whatever long running program(s) for which I want an audible alert once finished.  I often move on to other tasks when I have a long running program, and lose valuable time by not promptly returning to EG once it has finished.

 

If this hasn't been created before, can someone post the custom task shell code for a custom task that has no interface, just calls some .Net code?  I'm busy and don't have time ATM to hit the docs.

 

Thanks...

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
5 REPLIES 5
ChrisHemedinger
Community Manager

This System Command custom task (GitHub) could be used as-is to run a command to play sound, or adapted for the specific "play a sound" action.

 

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!
ScottBass
Rhodochrosite | Level 12

Thanks @ChrisHemedinger esp for the pointer to the GitHub source code.

 

I'll use this as-is for now.  When I get more time, I'd like to create just a simple beep task.

 

Can you tell me the bare minimum code sections I would need to execute embedded C# code without any user interface?

 

For example, I assume I can delete:

 

using System.Windows.Forms;
using System.Xml;		    // for XMLTextWriter and XMLTextReader
using System.IO;		    // for StreamReader and StreamWriter

and all the code sections that call these methods?

 

P.S.:  I've got your book but it's at the office and we're all in lock down 😒

 

 

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
TomKari
Onyx | Level 15

Another approach if your SAS is on Windows. I've never heard of this routine!!

 

data _null_;
   call sound(523,2000);
run;

I was googling...here's where I found it!

 

Tom

 

https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/048-29.pdf 

ScottBass
Rhodochrosite | Level 12

@TomKari wrote:

Another approach if your SAS is on Windows. I've never heard of this routine!!

 

data _null_;
   call sound(523,2000);
run;

I was googling...here's where I found it!

 

Tom

 

https://support.sas.com/resources/papers/proceedings/proceedings/sugi29/048-29.pdf 


Hi Tom,

 

This only "works" for DMS.  I say "works" because it probably works for EG too, playing the sound on the machine in a server room in a galaxy far, far away.  If that server has a sound card.  And is not on mute.

 

😁


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
TomKari
Onyx | Level 15

Yes, good point.

 

I use EG with a local server instance, so I sometimes forget to separate the functions. Also, I was so surpised that there is a "sound" routine that all other thoughts were scattered to the winds. Who the heck put THAT in SAS?

 

I must admit, I am amused by the thought of a server in a computer room starting to play tunes...maybe use a grid, and have it switch from server to server, so the server room staff can't chase it down?

 

Tom

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 2565 views
  • 3 likes
  • 3 in conversation