We’re smarter together. Learn from this collection of community knowledge and add your expertise.

Tips for Programming Efficiently in SAS Studio

by SAS Employee samdupont ‎12-15-2015 12:18 PM - edited ‎02-01-2017 05:37 PM (5,283 Views)

Perform actions without taking your hands off the keyboard. Compare data side by side. Declutter your workspace to maximize precious space. These are some of the invaluable features of SAS Studio to help you code effectively and efficiently. Read on for some quick tips on how to maximize your coding experience. Read SAS Studio 3.6 new features for some more great tips.

 

New in SAS Studio 3.6

Select and Edit Columns in the Editor 

You can Alt+mouse drag to select columns of data (as opposed to rows).

 

SelectColumns.png

 

Then you can start editing those columns.

EditColumns.png

 

 

Keyboard Shortcuts

 

GENERAL

WINDOWS

MAC

Maximize / restore workspace

Alt+F11

Fn+Option+F11

New SAS program

F4

Fn+F4

Submit / Run

F3

Fn+F3

Reset the SAS session

F9

Fn+F9

Print the SAS program, log, or results.

Ctrl+P

Cmd+P

Move the focus to the Server Files and Folders section label.

Alt+1

Option+1

Move the focus to the label of the currently displayed secondary tab. Cycle between the secondary tabs.

Alt+2

Option+2

Move the focus to the label of the currently displayed primary tab and then navigate among all open tabs in the work area.

Alt+3

Option+3

Move the focus to the body of the Code tab on the currently displayed primary tab.

Alt+4

Option+4

Move the focus to the selected item in the Log tab on the currently displayed primary tab.

Alt+5

Option+5

 

 

CODE EDITOR

WINDOWS

MAC

Convert to uppercase

Ctrl+U

Ctrl+U

Convert to lowercase

Ctrl + L

Ctrl + L

Cycle through cases

Ctrl+Shift+U

Cmd+Shift+U

Create new snippet

Alt+A
Shift+Alt+A

Cmd+Alt+A

Insert a snippet

Alt+I
Shift+Alt+I

Cmd+Alt+I

Toggle comments on and off

Ctrl+/
Ctrl+Shift+C

Cmd+/

Cmd+Shift+C

Autocomplete

Ctrl+Spacebar

Ctrl+Spacebar

Navigate between autocomplete and help.

Tab, Shift+Tab

Tab, Shift+Tab

Select a column*

Alt+drag

 

* New in SAS Studio 3.6

 

Features in SAS Studio 3.5+

 

Shortcut keys - more details

Use shortcut keys to quickly navigate to primary workspace areas

There are a set of shortcut keys that take you wherever you are in the application to the three main areas of SAS Studio.

  • Alt+1 – Use this shortcut to quickly jump to the first pane in the navigation area. Usually this is the Files and Folders pane. 
  • Alt+2 – This shortcut will take you to one of the Code window tabs. Once there, you can use the arrow keys or Alt+2 to toggle between the Code, Log, Results, and Output (if displayed) tabs.
  • Alt+3 –This shortcut puts focus on the active primary tab. You can then use the arrow keys or Alt+3 to toggle through all the open tabs.
  • Alt+4 - Takes you directly to the code window.

Submit selected code vs entire program

F3 (Fn+F3) has been the keyboard shortcut for submitting SAS code. If you have nothing selected, F3 (Fn+F3) will run the entire program. If you select only some of the code, F3 (Fn+F3) will submit just the selected code. Great when you want to test out a part of your program. Note: The log is overwritten each time you submit.

 

Display autocomplete only when you need it

Autocomplete is a useful tool when needed but a major annoyance when not needed. Ctrl+Spacebar (Command+Spacebar) allows you to turn SAS autocomplete on for a particular command. First, turn off autocomplete in Preferences. To do this: From the banner, select the More applications options menu icon (to the left of the help icon) and then select Preferences. Go to the Editor section and uncheck the Enable autocomplete option. Click OK to save. Once you’ve done that, use Ctrl+Spacebar (Command + Spacebar) whenever you want to display the appropriate autocomplete tool.

 

Maximize your workspace

Collapse the navigation panes by using Alt+F11 (Option+F11). Press it again to show the navigation panes. You can also double-click a primary tab to toggle between hiding and showing the navigation panes. 

Refer to keyboard shortcuts for more shortcuts.

 

Submission historySubmission history list

If you submit a program or parts of a program over and over again you can quickly go back in history to see past submitted code, logs and results. From the code window's toolbar, select the Submission History icon (the one to the right of the running man). You will see a list of the submissions. Click one to see the code and its associated log and results.

 

Tab layout

Rearrange the code tabs - side by side or stacked

How do you like to arrange your coding window? Code at the top, log at the bottom, results on the right? Select and drag the Code, Log, Results, and Output tabs to the various drag zones: top, right, left, and bottom. Your new and preferred layout is persisted until you change it.

 Compare tabs

Compare data side by side

Want to view two data sets or two code windows side by side? Easy. For a vertical side by side comparison, select and drag the primary tab to the right-hand side of the SAS Studio window. For a horizontal side by side comparison, select and drag the primary tab to the bottom of the window. 

 

 

 

 

If you have multiple monitors you can use this to expand your workspace area to display lots more information. Resize your 
SAS_Studio_data_comparison.png

browser so that it extends across multiple monitors. Drag a primary tab to the right side’s drop zone to show up on the second monitor.

Or you can open a second or third instance of SAS Studio to display different data on a second monitor.

 

 

 

 

 

Create new files

Right-click on a primary tab to create instances of programs, queries, imports, and process flows. (Note: Process flows are available only in the Visual Programmer perspective).

 

Close all tabs

Right-click on a primary tab and select Close All to close all tabs.

 

Add table and variable names to your code

Typing table and variable names can be error prone not to mention tedious. You can quickly select and drag a library or its variables into your code to insert their names.Drag and drop variables

To do so: Place the cursor in your code where you want to insert the name. From the Libraries pane in the navigation area, locate the library whose name and variables you want to add to your code.

To insert the library, select and drag the library into your code. The name will be inserted where your cursor is positioned. For example if you select SASHELP.CLASS, SAS Studio will insert SASHELP.CLASS into your code.

To insert a bunch of variable names into your code, open the library, select all the variables you want to add and drag them over. The variables are inserted in the order that they are selected.

 

 

 

 

 

 

 

Personalize the navigation panes

Unclutter your navigation panes by turning off things you’ll never use. For example, many programmers don’t use file shortcuts, so why have it around taking up precious space and cluttering up your workspace. To show and hide panes, go to the More application options menu in the banner. Select View and turn off those panes that you want to hide.

Comments
by Super User
on ‎12-15-2015 12:23 PM

The Multiple Monitors aspect of SAS Studio is one that could convince me to switch! I really wish Base SAS somehow supported using multiple monitors.

by Regular Contributor
on ‎12-15-2015 07:39 PM

I use SAS Studio (well, actually University Edition) on a Mac and didn't know about the multiple monitors!  That's so cool :-)

by New Contributor RonScala
on ‎03-29-2016 03:30 PM

These tips are great!  

 

Is there a tip for the following?

 

After submitting selected code and returning to the code tab - the focus returns to the first line of code - is there a way to keep the focus on the selected code so you can pick up where you left off?

by SAS Employee samdupont
on ‎03-29-2016 04:03 PM

@RonScala

 

Try this. 

 

  1. Select some code.
  2. Press F3 / or use Running man icon to submit your code.
  3. The Log/Results/Output tab opens.
  4. Use Alt+4 (Option+4) to switch back to the code window and return focus to the selected code. 

To move out of the selected state you can do the following depending on what you want:

  • HOME (Command+left arrow) moves cursor to the beginning of the first line of the selected code
  • END (Command+right arrow)  moves cursor to the end of the first line of the selected code
  • RIGHT ARROW moves cursor to the end of the selected code

 Hope that helps. 

 

by New Contributor RonScala
on ‎04-01-2016 01:49 PM

Thanks for the tip on SAS Studio! However it did not work for me - probably because I am on a MAC connecting through Citrix and Remote Desktop.  My collegue is on a Windows machine so I will have him try...  I will let you know how we make out.

by Contributor Michelle
on ‎02-15-2017 02:22 PM

AWESOME tips--I am especially happy to find out about the side-by-side code tabs! My org is converting from Foundation to Studio and I miss some of the bells and whistles of the Enhanced Editor. One of which is the ability to collapse the data/proc steps (e.g., edit->collapse all). Is this possible in Studio? If not, can you add it to the wish list? I have some programs with hundreds of lines, and collapsing the data/proc steps makes it easier to navigate and review the code.

by SAS Employee samdupont
on ‎02-15-2017 03:43 PM

Hi @Michelle,

 

Glad you like the tips. The ability to fold code (collapse procs/data steps) is a very high priority item on the roadmap and will be coming out in a future release. As you continue to use Studio, please let us know any other bells and whistles that you miss. 

 

Thx,


Sam

by Valued Guide
on ‎02-16-2017 07:09 AM

another whistle, I have still to find in SAS Studio, 

or has still to be added, 

is jumping between ( and ) 

and     between DO and END

 

Jumping between open and close parentheses (at correct levels) in  Enterprise Guide code editor is done with ctrl+( or ctrl+ any other ({[ key

Jumping between DO and matched END is done with alt+( or alt+[ etc

 

saddened to miss these

 

 

by SAS Employee samdupont
on ‎02-16-2017 09:28 AM

Hi,

 

This is definitely on the roadmap for a future release (it has a status of critical). When I know the exact release I will update this thread.

 

Thanks for the input as the more input we get the higher the priority a request becomes.

 

Sam

by Contributor SuzanneDorinski
on ‎05-05-2017 02:06 PM

I've used SAS Display Manager for many years.  I now have SAS Studio at work.  I noticed that Results in SAS Studio using HTMLBlue are smaller than the Results in HTMLBlue from the same program run in SAS Display Manager. 

 

I've tried the other output styles in SAS Studio.  Most of them seem too small.  The StudioDemo style looks like HTMLBlue but seems too large.  (I'm assuming based on the style name that it's intended for doing demonstrations with SAS Studio.)

 

I looked at the font defintions for HTMLBlue and StudioDemo, then tried a version that is midway between the two styles.  It would be great if SAS would consider including a style like this (see below) in a future release.

 

Others have noticed the font size issue in the Results window --  https://communities.sas.com/t5/SAS-Analytics-U/change-font-size-in-Results-window/m-p/158591/highlig....

 

proc template;
  define style Styles.HTMLBlueMidSize;
    parent = styles.HTMLBlue;
    style fonts /
       'TitleFont2' = ("<sans-serif>, <MTsans-serif>, Helvetica,Helv",4,
       bold)
       'TitleFont' = ("<sans-serif>, <MTsans-serif>, Helvetica, Helv",5,
       bold)
       'StrongFont' = ("<sans-serif>, <MTsans-serif>, Helvetica, Helv",4,
       bold)
       'EmphasisFont' = ("<sans-serif>, <MTsans-serif>, Helvetica,Helv",4,
       italic)
       'FixedFont' = ("<monospace>, Courier",4)
       'BatchFixedFont' = ("SAS Monospace, <monospace>, Courier, monospace"
       ,4)
       'FixedHeadingFont' = ("<monospace>, Courier, monospace",4)
       'FixedStrongFont' = ("<monospace>, Courier, monospace",4,bold)
       'FixedEmphasisFont' = ("<monospace>, Courier, monospace",4,italic)
       'headingEmphasisFont' = (
       "<sans-serif>, <MTsans-serif>, Helvetica,Helv",4,bold italic)
       'headingFont' = ("<sans-serif>, <MTsans-serif>, Helvetica,Helv",4,
       bold)
       'docFont' = ("<sans-serif>, <MTsans-serif>, Helvetica, Helv",4);
  end;
run;

  

 

 

by Super User
on ‎05-05-2017 02:13 PM

@SuzanneDorinski I think part of the issue with working with web browser is it probably depends on the zoom level to some degree. Some people set their zoom level and forget it's set. If you reset to Actual things usually look correct. 

 

I agree with you regarding different styles though and look forward to testing yours out soon ;)

by Contributor SuzanneDorinski
on ‎05-05-2017 02:36 PM

My browser is set at 100%.  I'm using SAS Studio in a virtual environment.  The way it's set up, I click on an icon to start SAS Studio, so it starts in the default browser.  In my case, that's Internet Explorer.  I'd rather not adjust the zoom in the browser, because then it affects settings for my web mail and internet / intranet browsing.  I'd provide screen shots, but I don't see how to add them here.  My agency has some on-site technical advisors, so I'll provide screen shots to them.

by SAS Employee samdupont
on ‎05-08-2017 01:45 PM

 

In 9.4m5, we will introduce a new style called HTMLEncore. It will be a child of HtmlBlue but with more readable font-size and fonts. It will be available with SAS Studio 3.7 which should be released sometime in the 4th quarter 2017. 

Your turn
Sign In!

Want to write an article? Sign in with your profile.