Managing the SAS Registry

Primary Concerns about Managing the SAS Registry

CAUTION:
If you make a mistake when you edit the registry, your system might become unstable or unusable.
Whenever possible, use the administrative tools, such as the New Library window, the PRTDEF procedure, Universal Print windows, and the Explorer Options window, to make configuration changes, rather than editing the registry. This is to ensure that values are stored properly in the registry when changing the configuration.
CAUTION:
If you use the Registry Editor to change values, you are not warned if any entry is incorrect.
Incorrect entries can cause errors, and can even prevent you from starting a SAS session.

Backing Up the SASUSER Registry

Why Back Up the SASUSER Registry?

The SASUSER(footnote1) part of the registry contains personal settings. It is a good idea to back up the SASUSER part of the registry if you have made substantial customizations to your SAS session. Substantial customizations include the following:
  • installing new printers
  • modifying printer settings from the default printer settings that your system administrator provides for you
  • changing localization settings
  • altering translation tables with TRANTAB

When SAS Resets to the Default Settings

When SAS starts up, it automatically scans the registry file. SAS restores the registry to its original settings under two conditions:
  • If SAS detects that the registry is corrupt, then SAS rebuilds the file.
  • If you delete the registry file called regstry.sas7bitm, which is located in the SASUSER library, then SAS restores the SASUSER registry to its default settings.
    CAUTION:
    Do not delete the registry file that is located in SASHELP; this prevents SAS from starting.

Ways to Back Up the Registry

There are two methods for backing up the registry and each achieves different results:
Method 1: Save a copy of the SASUSER registry file called regstry.sas7bitm.
The result is an exact copy of the registry at the moment that you copied it. If you need to use that copy of the registry to restore a broken copy of the registry, then any changes to the registry after the copy date are lost. However, it is probably better to have this backup file than to revert to the original default registry.
Method 2: Use the Registry Editor or PROC REGISTRY to back up the parts of the SASUSER registry that have changed.
The result is a concatenated copy of the registry, which can be restored from the backup file. When you create the backup file using the EXPORT= statement in PROC REGISTRY, or by using the Export Registry File utility in the Registry Editor, SAS saves any portions of the registry that have been changed. When SAS restores this backup file to the registry, the backup file is concatenated with the current registry in the following way:
  • Any completely new keys, subkeys, or values that were added to the SASUSER registry after the backup date are retained in the new registry.
  • Any existing keys, subkeys, or values that were changed after SAS was initially installed, then changed again after the backup, are overwritten and revert to the backup file values after the restore.
  • Any existing keys or subkeys (or values that retain the original default values) will have the default values after the restore.

Using the Explorer to Back Up the SAS Registry

To use the Explorer to back up the SAS Registry:
  1. Start SAS Explorer with the EXPLORER command, or select Viewthen selectExplorer.
  2. Select Toolsthen selectOptionsthen selectExplorer.
    The Explorer Options window appears.
  3. Select the Members tab.
  4. Select ITEMSTOR in the Type list.
  5. Click Unhide.
    If ITEMSTOR does not have an icon associated with it in the Type list, you are prompted to select an icon.
  6. Open the Sasuser library in the Explorer window.
  7. Right-click the Regstry.Itemstor file.
  8. Select Copy from the pop-up menu and copy the Regstry file. SAS names the file Regstry_copy.
    Operating Environment Information: You can also use a copy command from your operating environment to make a copy of your registry file for backup purposes. When viewed from outside SAS Explorer, the filename is regstry.sas7bitm. Under z/OS, you cannot use the environment copy command to copy your registry file unless your SASUSER library is assigned to an HFS directory.

Using the Registry Editor to Back Up the SAS Registry

Using the Registry Editor to back up the SAS registry is generally the preferred backup method, because it retains any new keys or values in case you must restore the registry from the backup.
To use the Registry Editor to back up the SAS Registry:
  1. Open the Registry Editor with the regedit command.
  2. Select the top-level key in the left pane of the registry window.
  3. From the Registry Editor, select Filethen selectExport Registry File.
    A Save As window appears.
  4. Enter a name for your registry backup file in the filename field. (SAS applies the proper file extension name for your operating system.)
  5. Click Save.
This saves the registry backup file in SASUSER. You can control the location of your registry backup file by specifying a different location in the Save As window.

Recovering from Registry Failure

This section gives instructions for restoring the registry with a backup file, and shows you how to repair a corrupt registry file.
To install the registry backup file that was created using SAS Explorer or an operating system copy command:
  1. Change the name of your corrupt registry file to something else.
  2. Rename your backup file to regstry.sas7bitm, which is the name of your registry file.
  3. Copy your renamed registry file to the SASUSER location where your previous registry file was located.
  4. Restart your SAS session.
To restore a registry backup file created with the Registry Editor:
  1. Open the Registry Editor with the regedit command.
  2. Select Filethen selectImport Registry File.
  3. Select the registry file that you previously exported.
  4. Click Open.
  5. Restart SAS.
To restore a registry backup file created with PROC REGISTRY:
  1. Open the Program editor and submit the following program to import the registry file that you created previously.
     proc registry import=<registry file specification>;
     run;
    This imports the registry file to the SASUSER library.
  2. If the file is not already properly named, then use Explorer to rename the registry file to regstry.sas7bitm:
  3. Restart SAS.
To attempt to repair a damaged registry:
  1. Rename the damaged registry file to something other than “registry” (for example, temp).
  2. Start your SAS session.
  3. Define a library pointing to the location of the temp registry.
    libname here '.'
  4. Run the REGISTRY procedure and redefine the SASUSER registry:
     proc registry setsasuser="here.temp";
     run;
  5. Start the Registry Editor with the regedit command. Select Solutionsthen selectAccessoriesthen selectRegistry Editorthen selectView All.
  6. Edit any damaged fields under the HKEY_USER_ROOT key.
  7. Close your SAS session and rename the modified registry back to the original name.
  8. Open a new SAS session to see whether the changes fixed the problem.

Using the SAS Registry to Control Color

Overview of Colors and the SAS Registry

The SAS registry contains the RGB values for color names that are common to most Web browsers. These colors can be used for ODS and GRAPH output. The RGB value is a triplet (Red, Green, Blue), and each component has a range of 00 to FF (0 to 255).
The registry values for color are located in the COLORNAMES\HTML subkey.

Adding Colors Using the Registry Editor

You can create your own new color values by adding them to the registry in the COLORNAMES\HTML subkey:
  1. Open the SAS Registry Editor using the REGEDIT command.
  2. Select the COLORNAMES\HTML subkey.
  3. Select Editthen selectNew Binary Value. A pop-up menu appears.
  4. Enter the color name in the Value Name field and the RGB value in the Value Data field.
  5. Click OK.

Adding Colors Programmatically

You can create your own new color values by adding them to the registry in the COLORNAMES\HTML subkey, using SAS code.
The easiest way is to first write the color values to a file in the layout that the REGISTRY procedure expects. Then you import the file by using the REGISTRY procedure. In this example, Spanish color names are added to the registry.
filename mycolors temp;
data _null_;
   file "mycolors";
   put "[colornames\html]";
   put ' "rojo"=hex:ff,00,00';
   put ' "verde"=hex:00,ff,00';
   put ' "azul"=hex:00,00,ff';
   put ' "blanco"=hex:ff,ff,ff';
   put ' "negro"=hex:00,00,00';
   put ' "anaranjado"=hex:ff,a5,00';
run;

proc registry import="mycolornames"; 
run;
After you add these colors to the registry, you can use these color names anywhere that you use the color names supplied by SAS. For example, you could use the color name in the GOPTIONS statement as shown in the following code:
goptions cback=anaranjado;
proc gtestit;
run;

Using the Registry Editor

When to Use the Registry Editor

The best way to view the contents of the registry is using the Registry Editor. The Registry Editor is a graphical alternative to PROC REGISTRY, an experienced SAS user might use the Registry Editor to do the following:
  • View the contents of the registry. The registry shows keys and values stored in keys.
  • Add, modify, and delete keys and values stored in the registry.
  • Import registry files into the registry, starting at any key.
  • Export the contents of the registry to a file, starting at any key.
  • Uninstall a registry file.
  • Compare a registry file to the SAS registry.
Many of the windows in the SAS windowing environment update the registry for you when you make changes to such items as your printer setting or your color preferences. Because these windows update the registry using the correct syntax and semantics, it is often best to use these alternatives when making adjustments to SAS.

Starting the Registry Editor

To run the Registry Editor, issue the regedit command on a SAS command line. You can also open the registry window by selecting Solutionsthen selectAccessoriesthen selectRegistry Editor.

Finding Specific Data in the Registry

In the Registry Editor window, double-click a folder icon that contains a registry key. This displays the contents of that key.
Another way to find things is to use the Find utility.
  1. From the Registry Editor, select Editthen selectFind.
  2. Enter all or part of the text string that you want to find, and click Options to specify whether you want to find a key name, a value name, or data.
  3. Click Find.
The Registry Editor Find Utility
The Registry Editor Find Utility

Changing a Value in the SAS Registry

CAUTION:
Before modifying registry values, always back up the regstry.sas7bitm file from SASUSER.
  1. In the left pane of the Registry Editor window, click the key that you want to change. The values contained in the key appear in the right pane.
  2. Double-click the value.
    The Registry Editor displays several types of windows, depending on the type of value that you are changing.
Example Window for Changing a Value in the SAS Registry
Example Window for Changing a Value in the SAS Registry

Adding a New Value or Key to the SAS Registry

  1. In the SAS Registry Editor, right-click the key that you want to add the value to.
  2. From the pop-up menu, select the New menu item with the type that you want to create.
  3. Enter the values for the new key or value in the window that is displayed.
Registry Editor with Pop-up Menu for Adding New Keys and Values
Registry Editor with Pop-up Menu for Adding New Keys and Values

Deleting an Item from the SAS Registry

From the SAS Registry Editor:
  1. Right-click the item that you want to delete.
  2. Select Delete from the pop-up menu and confirm the deletion.

Renaming an Item in the SAS Registry

From the SAS Registry Editor:
  1. Right-click the item that you want to rename.
  2. Select Rename from the context menu and enter the new name.

Displaying the SASUSER and SASHELP Registry Items Separately

After you open the Registry Editor, you can change your view from the default. The default view shows the registry contents without regard to the storage location. The other registry view displays both SASUSER and SASHELP items in separate trees in the Registry Editor's left pane.
  1. Select TOOLSthen selectOptionsthen selectRegistry EditorThis opens the Select Registry View group box.
  2. Select View All to display the SASUSER and SASHELP items separately in the Registry Editor's left pane.
    • The SASHELP portion of the registry is listed under the HKEY_SYSTEM_ROOT folder in the left pane.
    • The SASUSER portion of the registry is listed under the HKEY_USER_ROOT folder in the left pane.
The Registry Editor in View Overlay Mode
The Registry Editor in View Overlay Mode

Importing a Registry File

You usually import a registry file, or SASXREG file when you are restoring a backup registry file. A registry file can contain a complete registry or just part of a registry.
To import a registry file using the SAS Registry Editor:
  1. Select Filethen selectImport Registry File.
  2. In the Open window, select the SASXREG file to import.
Note: In order to first create the backup registry file, you can use the REGISTRY Procedure or the Export Registry File menu choice in the Registry Editor.

Exporting a Registry File

You usually export a registry file or SASXREG file, when you are preparing a backup registry file. You can export a complete registry or just part of a registry.
To export a registry file using the SAS Registry Editor:
  1. In the left hand pane of the Registry Editor, select the key that you want to export to a SASXREG file. To export the entire registry, select the top key.
  2. Select Filethen selectExport Registry File.
  3. In the Save As window, give the export file a name.
  4. Click Save.
FOOTNOTE 1:The SASHELP part of the registry contains settings that are common to all users at your site. SASHELP is Write protected, and can be updated only by a system administrator.[return]