Hands-on 04: SAS Enterprise Guide
SAS Enterprise Guide is a powerful Microsoft Windows client application that provides a guided mechanism to exploit the power of SAS.
Starting with SAS Enterprise Guide 8.4, it is now possible to directly connect to and leverage the capabilities of a SAS Viya Compute Server.
Connect to SAS Enterprise Guide
For this exercise, you’ll have to connect to a different machine where SAS Enterprise Guide has been installed.
-
Click this link to get the machine assigned to you. Clicking the link will open an Azure Bastion login page.
- Enter the username student and password Metadata0Metadata0 .
-
Double click the SAS Enterprise Guide icon on the desktop to start it.
You will be greeted by the SAS Enterprise Guide Start Page
Explore the Server Connections and sign into SAS Viya
- From the main menu, select the Tools -> Connections. The Connections window appears.
-
From the selection pane in the Connections window, select Servers, then SAS Viya Server, and click the Modify button.
-
The Add SAS Server window appears. Have a look at the definitions we have pre-defined for you - but do not change anything!
-
The Server field lists the address used to connect to the SAS Viya environment.
For a SAS Viya connection you use a URL instead of a machine name.
-
The Compute Context Name lists the compute context used to start a compute server in SAS Viya.
A compute context represents configuration items like default assigned SAS libraries and autoexec. The default is SAS Studio compute context: this is the default SAS Viya compute server definition that is also used by SAS Studio, to ensure consistency between client applications. If you want, you can define and use a different one specific for SAS Enterprise Guide.
- The File navigation box defines the computer server directory that SAS Enterprise Guide shows in the Servers pane.
- Some fields that are only used with SAS 9 servers and do not apply to SAS Viya servers are grayed out.
-
- Click Cancel, then Close to go back to the main window.
-
All defined connections show up in the Servers panel.
Select the SAS Viya Server and click the arrow next to it, or select Connect from the popup menu. This will open a tab in your default web browser showing a SASLogon window asking for user credentials - it’s the same process we encountered in the previous exercise to sign in to VSCode. Just accept the pre-filled student username and password and sign in. The SAS Logon page gives you an authorization code.
-
Select this Authorization Code and copy it to the clipboard, then paste it into the Authenticate with SAS Viya panel that opened in SAS Enterprise Guide and click on OK.
Congratulations, SAS Enterprise Guide is now connected to SAS Viya!
Browse a SAS data set
-
Just like you did with VSCode, you can use SAS Enterprise Guide to explore data. In the Servers panel, expand Libraries -> SASHELP, then double click the CARS table to open it. A new table viewer windows will open to let you browse the table. This view is read-only, there is no risk to inadvertently change your data.
-
Explore the menu bar at the top of the table. You have commands to subset your data with a quick filter, or use the interactive Query Builder to build more complex queries. You can also open a task using this data set, and export the data or open it in another program (Microsoft Excel, Microsoft Word, etc.).
-
Close the table viewer.
Open an existing project, convert and execute it
-
From the Project panel, select Open an existing project. The Open window appears. Select My Computer -> Browse. Another Open window appears. Select Documents, CARS_LinearModel, then click Open.
-
A new Process Flow window opens. A banner at the top informs you that this project was saved from a different environment, and, if you try to run the project, you’ll get an error informing you that the server used to create this project is not available in the current environment. This is expected, because this project was created in a SAS 9 environment that is not available anymore.
-
To convert the project to execute in this new SAS Viya environment, select Tools -> Project Maintenance from the main menu. A pop-up window informs you the you must save and close the project to perform this action. Accept by clicking Close and Continue.
-
The Project Maintenance window opens. Here is where you can map the previous server to the new one. Select Servers -> SASApp, then click Replace in Project. The Replace SAS Execution Server window appears. Expand Servers, select SAS Viya Server, then click OK and again OK. Confirm when asked to save your changes.
-
The project is now ready to execute in SAS Viya. Select the Ready label at the lower right of the main window to open the Submission Status panel. This lets you monitor the execution of the nodes in the project. Select Run and watch the status update in real time. Notice that the execution server is the SAS Viya Server.
-
You can find the analysis results in the HTML - Linear Models node. You can double click on the node to open it, then scroll the page to see all the resulting tables and graphics. Close the panel when done.
Add Python code to the project
One of the big advantages of using SAS Enterprise Guide with SAS Viya is that you can mix and match SAS code with other languages, such as Python. Let’s add a new node, with the Python code that we run in the previous VSCode exercise, to the Process Flow we just used.
-
In the Process Flow panel, right click on the blank space below the Linear Models node and select Add new -> Program. A new Program node appears. Double click it to open it.
-
Copy the following code and paste it in the Program panel that opens, then select Run to execute it.
proc sort data=sashelp.cars out=work.cars_sorted; by origin; run; proc python; submit; import matplotlib.pyplot as plt df = SAS.sd2df('work.cars_sorted') ax = plt.bar(df['Origin'], df['MSRP']) SAS.pyplot(plt) endsubmit; run; filename sock clear;
This small program shows how simple it is to use SAS Enterprise Guide, connected to SAS Viya, to share data and results between SAS and Python.
This is the end of the exercise. Please close the browser window hosting the remote SAS Enterprise Guide environment.