As the first step in the decommissioning of the site has been converted to read-only mode.

Here are some tips for How to share your SAS knowledge with your professional network.

Setting Up SAS Studio

From sasCommunity
Jump to: navigation, search

SAS University Edition -- setting up SAS Studio for tool usage


this page provides programs to discover how SAS Studio works and how to set up folders that contain programs for usage as %includes and autocall macros.
show programmers an example of how to use SAS Studio with reusable programs

Folder Naming Conventions

The instructions for setting up SAS Studio folders provide suggested folder names.

  • main: SASUniversityEdition is suggested, this is a user choice
  • child: myfolders, this is specific, SAS-Studio will not run without this folder name


This is the folder structure used here.

Directory of C:\SAS-univ-edition
<DIR> myfolders
      <DIR> discovery
            <DIR> sas
            <DIR> sas7b
      <DIR> RnD
            <DIR> sas
            <DIR> sas7b
      <DIR> SAS-site
            <DIR> includes
            <DIR> macros


List of Files





Notes: this file is named autoexec-site so that SAS-Studio will not %include it.

%put &=userdir;
filename site_inc  "&userdir/SAS-site/includes";
filename site_mac  "&userdir/SAS-site/macros";
options  mautosource sasautos=
(project site_mac "SASEnvironment/SASMacro" sasautos);

discovery echo-global-symbol-table

This file is used to echo the Global Symbol Table to the log.

%put environment variables from configuration file(s);
%put %sysfunc(getoption(set));
%put %sysget(sasroot);
%put %sysget(sasautos);
%put autocall macro options: mautosource is boolean;
%put %sysfunc(getoption(mautosource));
%put autocall macro options: sasautos is filerefs;
%put %sysfunc(getoption(sasautos));
%put instantiate fileref sasautos, check fileref in option sasautos;
%include sasautos(af)/nosource2;
%put %sysfunc(getoption(sasautos));
%put global macro variables, SAS;
%put _automatic_;
%put global macro variables, SAS-Studio;
%put _global_;
*name of program has special characters masked;
%put %unquote(&_sasprogramfile);
%put filrefs: search paths for programs;
filename _all_ list;
%put librefs: search paths for data sets, catalogs;
libname  _all_ list;


environment variables from configuration file(s)
[SASROOT = /opt/sasinside/SASHome/SASFoundation/9.4]
[SASAUTOS = ('!SASROOT/sasautos' )]

autocall macro options mautosource: boolean
62         %put %sysfunc(getoption(mautosource));
63         %put autocall macro options sasautos: filerefs;
autocall macro options sasautos: filerefs
64         %put %sysfunc(getoption(sasautos));
( "SASEnvironment/SASMacro" '!SASROOT/sasautos' )


  • In SAS the value of option sasautos is the single fileref sasautos.
  • The fileref sasautos has the list of folders in the environmental variable sasautos.
  • the first directory-specification is enclosed in double quotes, which usually indicates there are macro variables in the string
  • the second directory-specification is enclosed in single quotes, which is okay when referencing an environment variable (!SASROOT)

SAS global macro variables

global macro variables, SAS
96         %put _automatic_;
AUTOMATIC SYSVLONG4 9.04.01M2P-07-23-2014
AUTOMATIC SYSWARNINGTEXT Physical file does not exist,

SAS-Studio global macro variables

global macro variables, SAS-Studio
98         %put _global_;
GLOBAL USERDIR /folders/myfolders

102        %put %unquote(&_sasprogramfile);

Summary, Discovery

  • SAS-Studio is Linux
    • implication: Windows uses backward slash (\) in directory-specifications
    • Linux uses forward slash (/)
  • SAS-Studio provide a global macro variable userdir which contains the root directory-specification for use in filerefs and librefs
  • SAS-Studio will execute an file, if found in "&userdir"
  • macro variable _sasprogramfile does not contain special characters of directory-specifications, nor hyphens in filename

project RnD,

reminder: each project has folders: sas for programs and sas7b for data sets

This autoexec is for a project.

  • title for the project
  • provide a fileref project for project %includes
  • data sets and catalogs are in libref library
  •  %include the site autoexec to set access to site tools consistently
title1 'SAS univ.ed RnD';
filename project "&userdir/RnD/sas";
libname  library "&userdir/RnD/sas7b";
%include         "&userdir/";

project RnD,

project RnD,

Summary, Research and Development

SAS Studio

  • provides the ability to read an file during startup
  • provides global macro variables userdir that can be used to allocate filerefs and librefs
  • therefore, in the author's opinion, is a good tool for programmers


--Ronald_J._Fehd macro.maven == thoretical programmer