Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save FriedEgg/7dce842d09087f62e4ba04d4667c4ebc to your computer and use it in GitHub Desktop.

Select an option

Save FriedEgg/7dce842d09087f62e4ba04d4667c4ebc to your computer and use it in GitHub Desktop.
from win32com.client.dynamic import Dispatch
factory = Dispatch("SASObjectManager.ObjectFactoryMulti2")
serverDef = Dispatch("SASObjectManager.ServerDef") # no extra properties... local/zero-config server
sas = factory.CreateObjectByServer("SASApp", True, serverDef, "", "")
code = """
*pre-code;
filename _foo temp;
ods html5(id=_foo) file=_foo style=Pearl;
*code-code;
proc means data=sashelp.cars mean mode min max; run;
*post-code;
ods html5(id=_foo) close;
"""
sas.LanguageService.Submit(code)
_foo = sas.FileService.UseFileref("_foo")
tstream = _foo.OpenTextStream(1, 32767) # 1=StreamOpenModeForReading
results = ""
while True:
text = tstream.Read(1024)
results += text
if not text:
break
print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment