1

To aid in the ability to multitask, I added a datastep that would play the first three notes of hot cross buns after my program would finish, so I could just minimize SAS and do something else while it runs.

The thing is, I've had a few complaints from colleagues that they would forget that their volume was up all the way, and would receive a not-so-pleasant surprise when their program would complete.

Is there a way to pull in system info, more specifically, the computer volume level, so I can set a threshold in which the music will play or not?

Jared
  • 878
  • 3
  • 11
  • 19
  • Perhaps you could play the first three notes of [4'33"](http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3) instead? :-) – Joe Stefanelli Jan 24 '11 at 16:02
  • Haha. I didn't know what to expect and why this would be better at full volume. Well played, sir. – Jared Jan 24 '11 at 16:33
  • I forgot to mention a handy trick if you're using the Base SAS UI in windows is that once you have submitted a job you can double-click on the program on the task bar and the icon for the SAS job will change to an hourglass. Once it finishes it will return to the regular SAS icon. Handy if you want to keep an eye on it while doing other tasks. – Robert Penridge Dec 12 '11 at 00:00

2 Answers2

4

It can be done but is not easy or elegant - especially if you want to distribute the code. If you wanted to do it programmatically you would have to make a call to the relevant windows API DLL from SAS:

http://support.sas.com/documentation/cdl/en/hostwin/63285/HTML/default/viewer.htm#overdll.htm

As the article says it's not easy (and not guaranteed to work). The DLL you would be interested in is the one below:

Changing master volume level

A kludge solution would be to find a 3rd party program that takes command line calls to change the volume:

http://www.google.com/search?hl=en&client=firefox-a&hs=Tql&rls=org.mozilla%3Aen-US%3Aofficial&q=windows+change+volume+command+line&aq=f&aqi=&aql=&oq=

You could then call that using the 'x' comamnd in SAS. The issue here would be that you would need to install the 3rd party app on every machine that used your volume code.

Cheers Rob

Community
  • 1
  • 1
Robert Penridge
  • 8,424
  • 2
  • 34
  • 55
  • Oh yeah, this would be a bit too much, but you answered it! Do you think I'd maybe be able to build a VB script within SAS that'll do this for me? – Jared Jan 24 '11 at 18:03
  • Regardless of programming language you will always have to make the call to the DLL. The existing 3rd party tools to do this will be doing the same thing as well. – Robert Penridge Jan 24 '11 at 20:59
  • +1 As always Rob, the breadth of your knowledge impresses! – sasfrog Jan 24 '11 at 23:23
  • 1
    Thank you Rob. Would this method change if the only thing I needed was to return the level of volume rather than needing to change it? – Jared Feb 03 '11 at 16:20
1

I think the short answer is the the SAS SOUND function has two parameters: pitch and duration. Since volume is not a parameter, you can't control the volume without making a call to the OS.

Rick
  • 1,210
  • 6
  • 11