BookmarkSubscribeRSS Feed

Migrating from Enterprise Guide? Don't Leave Your Snippets Behind.

Started 3 hours ago by
Modified 16m ago by
Views 42

If you've built a library of user-defined snippets in SAS Enterprise Guide, you can bring them with you to SAS Studio. A user-defined snippet is a reusable code template, that enables you to quickly insert commonly used pieces of code into your programs.

 

Whether it's a DATA step template, a PROC SQL query, or an array processing routine, snippets can help reduce repetitive coding, improve consistency and increase productivity.

 

As of SAS Viya 2026.04, SAS Studio supports importing user-defined snippets exported from SAS Enterprise Guide, enabling you to continue benefiting from the reusable code templates you've developed over time.

 

 

Why Migrate Your Snippets?

 

Many SAS programmers build a personal library of snippets over time. These snippets often represent tried-and-tested solutions to common programming tasks and can save significant development effort.  

 

Common examples include:

 

/* Merge two data sets */

 

/* Replace the values in angle brackets before running */

 

data <output-table>;

 

merge <input-table-1> (in=in1)

 

<input-table-2> (in=in2);

 

by <merge-variable>;

 

run;

 

 

 

/* Create a new table from an existing table */

 

/* Replace the values in angle brackets before running */

 

proc sql;

 

create table <output-table> as

 

select <column-list>

 

from <input-table>;

 

quit;

 

 

 

/* Apply the same logic to multiple variables */

 

/* Replace the values in angle brackets before running */

 

data <output-table>;/font>

 

set <input-table>;

 

array vars {*} <variable-list>;

 

do i = 1 to dim(vars);

 

/* Add processing logic here */

 

if vars{i} < 0 then vars{i}=.;

 

end;

 

drop i;

 

run;  

 

 

While these examples are simple, snippet libraries often grow to include dozens or even hundreds of reusable coding patterns. Preserving these snippets when moving to SAS Studio helps ensure that valuable programming knowledge and productivity gains are not lost during the transition.  

 

 

Migrating Your Snippets

 

The following video demonstrates the complete migration process, from exporting user-defined snippets in SAS Enterprise Guide to importing them into SAS Studio.

 

(view in My Videos)

 

 

Step-by-Step Instructions

 

The migration process consists of two simple steps: exporting your snippets from SAS Enterprise Guide and importing them into SAS Studio.

 

  1. Exporting Snippets from SAS Enterprise Guide
    1. Open SAS Enterprise Guide.
    2. Select Program  Manage macros and snippets.
      Untitled Project (Time 0_00_02;09).png
    1. In the Manage Macros and Snippets window, select one or more snippets that you want to migrate. Untitled Project (Time 0_00_05;28).png
    2. Click Export and save the selected snippets as a KMF file. Untitled Project (Time 0_00_11;24).png
  1.  

The KMF file contains the snippet definitions and can be imported directly into SAS Studio.

 

  1. Importing Snippets into SAS Studio
    1. Open SAS Studio.
    2. In the Snippets pane, select Upload.Untitled Project (Time 0_00_15;04).png
    3. Browse to and select the exported KMF file.
    4. Upload the file into My Snippets. Untitled Project (Time 0_00_26;19).png
    5. SAS Studio imports the snippet definitions and makes them available in your personal snippets collection, under My Snippets. If your snippets do not appear immediately after the upload completes, simply log out of SAS Studio and sign back in.
    6. To use a snippet, open a SAS program, place the cursor where you want to insert the code, and then double-click the snippet or drag it from My Snippets into the code editor. If the snippet has an abbreviation, you can also type the abbreviation to insert the snippet.Untitled Project (Time 0_00_32;22).png

       

      The snippet it added to the code. 
      Untitled Project (Time 0_00_34;11).png

 

 

Conclusion

 

Migrating your user-defined snippets to SAS Studio preserves the reusable code templates you've developed over time. Once migrated, you can continue to build your library and, where supported, share snippets with colleagues. This helps teams promote coding standards, reduce duplicated effort, and work more efficiently across projects.

 

While the examples shown here use SAS code, snippets can also be used to store other reusable content and templates, for example, Python or HTML, making them a flexible productivity tool for a wide range of development tasks.

 

 

Find more articles from SAS Global Enablement and Learning here.

Contributors
Version history
Last update:
16m ago
Updated by:

Viya Copilot Motion Graphic.gif

Ready to see what SAS Viya Copilot can do?

Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.

Get Started →

SAS AI and Machine Learning Courses

The rapid growth of AI technologies is driving an AI skills gap and demand for AI talent. Ready to grow your AI literacy? SAS offers free ways to get started for beginners, business leaders, and analytics professionals of all skill levels. Your future self will thank you.

Get started

Article Tags