BookmarkSubscribeRSS Feed
Quentin
Super User

Hi All,

Seems there are often questions on here about "I want to make a little application with a graphical user interface for my SAS code, how can I do it?"

Was thinking it might be useful to have a thread that would summarize some of the current (and historical) approaches, and what people see as pros and cons of each.

I'm thinking historical approaches like:

  SAS/AF

  %WINDOW statement

More current approaches like:

  Integration Technologies a la http://support.sas.com/resources/papers/proceedings13/003-2013.pdf

  BI web reports

  Visual Analytics

  Others???

Does it seem worth the effort to ceate a thread with thoughts on this?  Perhaps ultimately to become a wiki page over at http://www.sascommunity.org ?  Just noticed there is no Application Development community, maybe that is worth asking for???


BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
14 REPLIES 14
Reeza
Super User

This is something I'm just getting into, basically how to provide a UI to SAS Macros without using EG.

I like the option of a thread on here.

FriedEgg
SAS Employee

On Windows I have worked with and built applications using Java, Python, C#/.NET (this would be the most relevant, usually), Ruby on Rails among others.  As long as the language has good hooks to COM/ActiveX for integrating with Integration Technologies Client, then you are good to go.  When you have additional tools from SAS, such as any of the tools which provide a web front-end to stored procedures, then you have that API at your disposal as well, whether that means developing inside that framework or making RESTful calls to it externally.

ballardw
Super User

What is this interface supposed to do with the code? Specifications before code is a real good idea.

Quentin
Super User

Fair question,   .

Most of the questions I see on here (and little applications I have built) are about pretty minimal interfaces.  So a simple inteface that allows a user to input a few parameters (drop down boxes, radio buttons, etc.) and then invokes some program.  And the program produces some report (html/pdf/rtf/etc.)  which is returned to the user.

I'm thinking of threads like:

https://communities.sas.com/message/138023#138023

https://communities.sas.com/message/171486#171486

https://communities.sas.com/message/207562#207562

https://communities.sas.com/message/211184#211184

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
ballardw
Super User

Once upon a time I would recommend SAS/AF but it seems that SAS is kind of ignoring that application.

Another one to look at is SAS/InterNet perhaps which doesn't require multiple users to have all kinds of licenses as I understand it.

I believe this page on Census.gov may use SAS/InterNet:

http://www.census.gov/cps/data/cpstablecreator.html

which is basically an interface to Proc Tabulate as far as I can determine. Previous versions of the site had output that actually had SAS in the description.

One thing about the site above, they have made it very difficult to actually save the results, the only way I have found is to copy paste into Excel as saving to HTM gets widgets but no output, print for many tables will not display entire results but I have to assume that is something in the way they configure the output/ page.

FriedEgg
SAS Employee

Here is a very simple GUI form for a macro submission and listing view using Python

import sys

from PySide.QtCore import *

from PySide.QtGui import *

import pythoncom

import win32com.client

import os

qt_app = QApplication(sys.argv)

objFactory = win32com.client.Dispatch( 'SASObjectManager.ObjectFactoryMulti2' )

objFactory.SetMetadataFile( 'C:/Users/' + os.getenv('USERNAME') + '/AppData/Roaming/SAS/MetadataServer/oms_serverinfo2.xml' , 'C:/Users/' + os.getenv('USERNAME') + '/AppData/Roaming/SAS/MetadataServer/oms_userinfo2.xml' , False )

objSAS = objFactory.CreateObjectByLogicalName('SASApp - Logical Workspace Server' , '')

objSAS.LanguageService.Submit('%macro macroexample(gender); proc means data=sashelp.class; var height weight; where sex="&gender"; run; %mend;')

class MacroExample(QWidget):

    def __init__(self):

        # GUI

        QWidget.__init__(self)

        self.setWindowTitle('SAS Macro Form')

        self.setMinimumWidth(400)

        self.layout = QVBoxLayout()

        self.form_layout = QFormLayout()

        self.genders = ['M','F']

        self.gender = QComboBox(self)

        self.gender.addItems(self.genders)

        self.form_layout.addRow('&Gender:', self.gender)

        self.result = QLabel('', self)

        self.form_layout.addRow('&Results:', self.result)

        self.layout.addLayout(self.form_layout)

        self.layout.addStretch(1)

        self.button_box = QHBoxLayout()

        self.button_box.addStretch(1)

        self.build_button = QPushButton('&Run SAS', self)

        self.button_box.addWidget(self.build_button)

        self.build_button.clicked.connect(self.submit)

        self.layout.addLayout(self.button_box)

        self.setLayout(self.layout)

    def submit(self):

        objSAS.LanguageService.Submit('%macroexample(' + self.gender.currentText() + '); run;')

        lst = []

        while 1:

            lst_part = objSAS.LanguageService.FlushList( 1000 )

            if not lst_part == '':

                lst.append( lst_part )

            else:

                break

        self.result.setText(''.join(lst))

    def run(self):

        self.show()

        qt_app.exec_()

app = MacroExample()

app.run()


initial.pngresults.png
Quentin
Super User

Thanks ,

Appreciate your list of options for languages, as well as your Python example. I'm curious what advice you would give for the following questioner (this is not quite me, but its who I have in mind):

"I'm an experienced SAS programmer familiar with ODS etc etc.  But I've never built an application that would be used by someone else.  It's always been me running my code, or giving SAS code to another SAS programmer who would run it.  Now I want to get into the application development game.  So instead of me running a report for somebody every montth, they can run it themselves.  And they can choose which subgroup they want to analyze, etc.  What approach / language do you think would be easiest for me to learn/use to develop the GUI ?  All I know is SAS. "

Assume this person has unlimited SAS access (so PC SAS, and BI server, and perhaps even  VA ...).

Do you suggest this person go learn enough Python to write something based on your example?  Or one of the other languages you listed?

Do you suggest this person go learn enough about Stored Processes to convert their report into a stored process (doesn't take much)?  If they go that approach, to you tell them to use VA as the user interface to run a stored process, or web report studio, or the default web forms generated by Stored Process Web App, or to learn enough web programming / javascript / CSS whatever to generate up their own custom web interface to pass parameters to the stored processes?

For me, I've been playing with some App Development for only the past couple years.  Most of it has been stored processes called by SPWA, but I haven't gotten into developing custom web interfaces, settling for the default interface generated by SPWA.  When a "customer" has had PC SAS available and the data was local, I've built a few little SAS/AF apps.

But I'm at a point now where I'm considering whether I should spend more time learning web tools (not sure which, happy for suggestions), so that I could build better, prettier interfaces for my web apps (stored processes), or if I should go the Python/.NET approach and start building my "own" apps, connecting in the background to SAS Workspace Server.

Thanks again for your thoughts,

--Q.


BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
AhmedAl_Attar
Rhodochrosite | Level 12

Quentin,

Here is my take on this interesting subject.

I would strongly recommend using Parametrized SAS Stored Processes (SAS Macro Programs) developed using MVC (Model-Viewer-Controller) design pattern. Here is why

  • Model: The application data, business rules, logic, and functions. (Custom query(ies), Data step & Procedures flows)
  • View: The screen/output presentation (Reformat the results depending on the Front-End Client)
  • Controller: Defines the way the user interface reacts to user input (Custom validation and value manipulation)

MVC decouples these three objects to increase flexibility and reuse.

I personally have been using the above approach for several years now, and I've had many success in re-using the same developed macros to serve different Front-End applications developed in different languages and technologies (Flex, JavaScript, .Net, HTML).

The typical protocol I've been using is HTTP Restful Web Services to communicate with SAS via good old SAS/IntrNet and SPWA.

Most if not all current programming languages and web frameworks support Restful Web Services, so the world is your oyster when it comes to choosing what to learn.

just my two cents,

Ahmed

FriedEgg
SAS Employee

Quentin,

There are a lot of big questions here, but I will focus first on one thing you mentioned:

Quentin wrote:

"I'm an experienced SAS programmer familiar with ODS etc etc.  [...]  All I know is SAS. "

Given this I would say staying inside the SAS/IntrNet and Store Process world is probably the best way to start and incorporating in custom interfaces utilizing a javascript framework.  A paper I recall that would be a good reference for this would be:

Developing Web Applications with SAS® Stored Processes

by Phil Mason

http://support.sas.com/resources/papers/proceedings14/1272-2014.pdf

Outside of this most of the approach someone would take would be dictated by the project at hand and it's business requirements.  If an application is necessary to build then the best place to start with no experience outside of the language of SAS would be something in the microsoft family (C#, .NET, VB, etc...)  The reason here being that the Integration Technologies documentation pretty much exclusively uses them for it's examples (with the exception being the JAVA specific interface also provided by SAS, which would be the best choice if you are not building your interfaces for the Windows OS).

As Ahmed states, and I mentioned earlier in the thread also, there are not really any limitations to what direction you go in.  It comes down to personal preference, the preferences of the client (or your company) and end-user of the application.

boemskats
Lapis Lazuli | Level 10

Quentin,

From this thread and your other one on using Oracle APEX I can see that you're pretty much looking to do what we've been doing for the last 3 years or so. I don't know what this forum's policy is on shameless self-promotion, but if you have a look at my profile info and check our website (/h54s) I think it'd probably help you a fair bit. Over the last few years we've developed a library that we've been using to develop some pretty sizeable operational enterprise information systems (1k+ concurrent users), using SAS as the data/analytics layer and HTML5 as the frontend. Ultimately it's similar to Phil Mason's excellent approach as suggested by just a lot simpler to use.

I suggest you get in touch with me if you want to see some examples.

thanks

Nik

jwillis
Quartz | Level 8

Nik,

"/h54s" is not working for me.  Please post your full web address.  Thank you.

boemskats
Lapis Lazuli | Level 10

Hi,

Sorry - have a look at boemskats.com/h54s and drop me an email if you want to see some live examples.

thanks

Nik

LoriGoldman
Obsidian | Level 7

Quentin,

I have similar questions.  I maintain applications on PC SAS where everyone who runs it has to have SAS installed on their PC.  The user interface is written in %Window.  We have a relatively new BI Server available, but I'm not sure how to go about converting the %Window interface into the new tools. Is it worth looking outside the SAS ecosystem? I think the first place to start is "what are the tools your organization can/will support"?  Python is open source software.  Just because it's open, doesn't mean your organization will allow you to download and work with it.  Even if they will, will they support it or any of the other tools mentioned?  If they don't, and even if you trained up enough that you could, would an application you built with other tools survive if you left your company?

jakarman
Barite | Level 11

Lori,  Within the BI server environment there is a prompting framework.  Prompting is targeted to be an userinteraction.
There are two locations that are:

- metadata defined, Stored processed and information maps are supporting that.

  SAS(R) 9.3 Stored Processes: Developer's Guide (Using Prompts)

  Several SAS clients can take advantage of the prompt.

- Eguide defined, Sound weird but Eguide should be able to run without a full blown metadataserver present.

  it is very similar http://support.sas.com/resources/papers/proceedings13/138-2013.pdf zie page 22 (flexibility).

  In this case the prompt is part of the EGP.

Both are using SAS macro variables to transport the information. Please avoid reserved common macro-vars.

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 14 replies
  • 8144 views
  • 8 likes
  • 9 in conversation