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.
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.
The following video demonstrates the complete migration process, from exporting user-defined snippets in SAS Enterprise Guide to importing them into SAS Studio.
The migration process consists of two simple steps: exporting your snippets from SAS Enterprise Guide and importing them into SAS Studio.
The KMF file contains the snippet definitions and can be imported directly into SAS Studio.
The snippet it added to the code.
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.
Visit the Tips & Tricks page for setup guidance, demos, and practical examples that show how Copilot supports your workflows.
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.