#10 SAS Studio Tricks You Should Know Today

SAS Studio is getting more popular than ever since it has launched. This is because of the boom in cloud technology and upcoming web migration.

The SAS Studio bundled with the SAS Viya is the perfect solution delivered by SAS and they are making improvements with each patch or a new version. 

You may have started using SAS Studio recently or maybe you’re already using it extensively but you should know these 10 hidden SAS Studio tricks. 

  1. Comment 
  2. Run selected code
  3. Program Summary
  4. Format code
  5. Visual Programmer
  6. Autoexec.sas file to set up Env. variables
  7. Create file shortcut (file reference)
  8. Insert file path
  9. Dark mode
  10. Interactive Interface

#1. Comment

There are many ways (total 7 proven ways) you can make a comment in SAS but you must know the most common and quickest way to make a comment.

The manual way to comment out every single line of code takes time. Imagine if you want to comment 100 lines of code from your SAS program. The easiest way to comment using keyboard shortcuts.

I’m assuming you’re using SAS Studio and want to comment out a few lines in the SAS code. It’s fairly easy. 

  • Select code which you want to comment
  • Press CTRL+star(*)
  • That’s it.

When you want to uncomment the commented lines of code then you need to do the same thing again .

  • Select code which you want to uncomment
  • Press CTRL+star(*)
  • That’s it.

#2. Run Selected Code

Sometimes you aren’t interested in running the entire SAS code, instead you just want to run selected lines of code. It’s absolutely possible in the SAS Studio with the minimal efforts.

All you have to do is, 

  • Select code which you want to execute
  • Press fn+F3 buttons on the keyboard.

Alternatively, you can just select code to execute and click on the RUN button. SAS will only execute selected lines of code.

The keyboard shortcut is also dependent on which browser you use. But you can run code by using FN+F3 or just the F3 button.

#3. Program Summary

Imagine if you want to save all your work that includes SAS code that you have executed, logs, along with the output, everything you can get in one click. 

The program summary option will be enabled as soon as you execute any query in SAS studio.

By clicking on the Program summary option from the top menu bar, a new browser window opens with all the details such as executed code, log, and output. It’s really a great option for quick documentation.

What you get in the program summary report:

  • Execution Environment 
  • Code: Program 1
  • Log: Program 1 
  • Results: Program 1

You don’t need to write separate code to generate reports like this. From the new browser window you can easily send it to the printer or save it as a PDF document.

SAS Studio tricks - program summary option

Program Summary output:

SAS Studio tricks - program summary option
SAS Studio tricks - program summary

#4. Format Code

The writing program is an art. You may be very good at writing complex logic in the code but what if you can’t showcase your art very well or what if others can’t read/understand it.

Programming structure or representation is also important for you as well as others who are going to maintain those codes. The briefly commented and formatted codes are highly recommended by many top SAS experts.

SAS has identified this issue and already given you one option to auto format your SAS code in one click. Look for the option “Format Code” available on the top menu bar. You can either format selected code or entire code by selecting the code and using this button. 

I couldn’t stress more to recommend you to use this option to format your code. It is highly-highly recommended.

SAS Studio tricks - format code

#5. Visual Programmer

Are you a SAS Enterprise Guide user? Or you have used SAS DI studio rigorously before and now started using SAS studio?

You must be used to the drag and drop feature. SAS Studio also provides you this feature. 

By default when you login on SAS Studio, it’s opened in the “SAS Programmer” set up. You can see it from the top right corner. There is a drop down available from where you can choose either “SAS Programmer” or “Visual Programmer” set-up.

SAS Studio tricks - SAS Visual Programmer

In the visual programmer set-up you can build a process flow by adding queries or filters or simply drag and drop datasets, files, any elements from “Tasks and Utilities”, “Snippets”, etc.

Most importantly, you can define the sequence of those elements by connecting the boxes through their respective control ports.

It’s a very powerful and visually appealing interface. In fact you build long, complex process flow and with one click generate SAS code immediately using the “Generate Code” button.

PS- This is the place where Data scientists build their models using existing lists of models such as predictive model, cluster analysis, linear model, forecasting etc.

#6. Autoexec file to set-up env variables

This is a real masterstroke and a very important feature you can have in the SAS Studio. As you already know SAS Studio is a web application integrated with cloud technology. 

The biggest reasons why companies have started using cloud solutions are easily maintained environments and cost saver. It is not necessary to have multiple cloud infrastructure environments for your Development, Test, or Production like the traditional enterprise architecture. 

You can literally have everything on the cloud with easily distinguishable parameters. Every time you open SAS Studio, it automatically executes the autoexec.sas file. 

At the beginning it’s empty but you may add environment specific parameters, references to the libraries, files, etc. The scope of that autoexec file is limited to that particular SAS studio as long as it is active. 

Considering the following sample parameters in the autoexec.sas file:

%let env=Production

libname ref ‘path-to-production-data’;

filename fref ‘path-to-production-data’;

Similarly, you can have separate settings for Development and QA environments.

I highly recommend you to consult with your SAS administrator before setting up the autoexec.sas file.

SAS Studio tricks - autoexec.sas file

#7. Create File Shortcut (file reference)

You don’t need to write filename statements or any sort of code to create file references. SAS Studio gives you functionality to create a quick file reference. 

  • Navigate to your file
  • Right click and create a new file shortcut
  • Give a name to file shortcut
  • Use that name directly in the code as FILE REFERENCE

So basically it replaces your filename statement in the code and makes it available as file reference. In thai context it is also known as file shortcut.

SAS Studio tricks - FILE SHORTCUT

#8. Insert File Path

For the quick file path insertion you can right click on the file and select option insert as a path. It automatically inserts file path with file name on the current selected area in the code editor.

In the below example I wanted to quickly insert a file path with file name to import data into SAS.

SAS Studio tricks - file Insert as a path

#9. Dark Mode (SAS Studio theme)

If you’re a hardcore programmer or developer then you’re gonna love this feature. This is not something new. Most of the programmers who write codes day-in day-out prefer dark mode over standard or light mode. It’s good for the eyes. 

You as a beginner might not like this feature but when you start using it then you’ll never switch back to standard mode.

SAS Studio gives you the option to select the SAS studio theme and my favorite is DARK MODE. What’s your favorite theme?

Go to Profile Setting>> Global>>General>>Choose a theme

SAS Studio dark mode theme
SAS Studio tricks - dark mode theme

#10. Interactive Interface

By default SAS studio is divided into three parts, first Explore, then Code Editor, and the Log window. This is also known as standard interface. You can switch from Standard interface to Interactive interface where you can move Log and result window at the bottom. 

So when you execute code, you will be able to monitor logs or see results without switching the windows. 

Go to Options>> Change perspective>> Select Interactive

SAS Studio Interactive Interface
SAS Studio tricks - Interactive Interface

You might not have access to all the features listed in this article due to SAS Studio versions. Your SAS Studio versions is older or latest than mine hence there would be some changes in the SASS Studio user interface.

That’s all about SAS Studio tricks and tips. Let me know your favorite SAS studio trick which you use more often.