33
SAS® Explorer Use and Customization Richard A. DeVenezia

SAS® Explorer Use and Customization Richard A. DeVenezia

Embed Size (px)

Citation preview

SAS® Explorer Use and Customization

Richard A. DeVenezia

Dad

1. More caffenie2. Work, then relax3. Take 15 min nap every hour4. Have fruit for snack instead of junk

food5. Splash water on face instead of

rubbing your eyes6. Soothing music while working

• A candle might help

Explorer

• Motif– Left hand side– Right hand side

• Windows, SAS, File Managers, Database Explorers, IDEs

SAS Environment

• Libraries

• File Shortcuts

• Favorite Folders

• My Computer

• Results

• Metadata

Active Components

• Customize

• First level nodes

• RegistryCORE\EXPLORER\INIT

Viewing Modes

• Explorer– Tree and List

• Contents Only– Just List

View Mode

• With icons– Large or Small– Left to right

• List– Small icons– Newspaper style

• Details– My favorite

Sorting Contents

• Details mode– click column header– no direction indicator like Windows Explorer

• View menu– Sort choice

Libraries node

• Contains a list of Library Items– One item per assigned LIBREF– Aka the list of LIBNAMES

Library node

Contains a list of Member Items

• Tables

• Views

• Catalogs

• MDDBs

Catalog member node

Contains a list of Catalog Entries

• Log, Output, Source

• Screen, Form

• Frame, SCL, Class

More than 60 catalog entry types!

Context Menu

• Every item listed in a “Contents of” Window has a right click popmenu

• Specific menu shown depends on item type– “Context” menu

Context Menus

• SAS Supplied Menu Items– Numerous– Sensible– Neat (View in Excel)

• Items also known as– Choices– Actions

Create a Menu Choice

• Menu: Tools / Options / Explorer...

• Command: EXPOPTS

Choices of an Item

• Know an Actions

• Action Command– Meat of an action

Item name parts

• Library Member– LIBNAME, MEMNAME

• Catalog Entry– LIBNAME, MEMNAME, OBJNAME,

OBJTYPE

Item type

• Explorer knows the type

• Library Members– TABLE, VIEW, MDDB, CATALOG– not surfaced to Action Command

• Catalog Entries– FRAME, SCL, OUTPUT, SLIST,...– At least 60 entry types– surfaced to Action Command

Action Command

• SAS Command– {Command} {Arguments}

• Arguments will want to deliver context to the command– The item name parts

Delivering Item Name Parts

• Library Member– %8b is replaced with LIBNAME– %32b is MEMNAME

• Catalog Entry– %8b is LIBNAME– %32b is MEMNAME– %32b is OBJNAME– %8b is OBJTYPE

Simple Action Command

• Library Member– DIR %8b Opens a DIRECTORY window, of which the member is in.

– FSVIEW %8b.%32; FORMULA Opens the member in FSVIEW and loads the default formula from

SASUSER.PROFILE.

Action Commands and Macro

% is reserved for %8b and %32b

%% passes % to command tokenization

• Catalog Entry– %%put picked:%8b.%32b.%32b.%8b Writes the catalog entry information to the SAS Log

Submitting Code

• GSUBMIT command

• Library Member– gsubmit ‘data _null_; put ”You picked: %8b.%32b.%32b.%8b”;run;’

Runs a DATA step that writes the library members name information to the SAS Log

Running SAS/AF programs

• AFA command

• Library Member– afa c=sasuser.myhandlers.foo.scl entry=%8b.%32b

Runs a SAS/AF SCL program that is passed the name information of the library member right clicked on.

SAS/AF arguments

• Passed in the local environment list

declare char NAME='entry';declare char VALUE= getNitemC ( getNitemL ( envlist('L'), '_CMDLIST_' ) , NAME, 1, 1, '‘ );

put NAME= VALUE=;

Running SAS/AF programs

• Some interesting SAS actions are implemented in SAS/AF

Copy_to_clipboard Copy a Table to the Clipboard as HTML

Excel_table_open Open a SAS Table in Excel

Save_as_html Save a SAS Table as HTML

Open_html_entry Open an HTML entry with WBROWSE

Open_sas_file Open a SAS7BDAT or SAS7BCAT file

Open_file Example Action for processing a file

Open_catalog_entry Example Action for Processing a Catalog Entry

Autocall Macros

• Centralize the Action Command coding task

• Proper place for lengthy amounts of code– Do not want to clutter SAS registry with lots of

code that is hard for a coder to reach

• Deployable to other users

Programmatic Customization

• Avoid tedious mousing around

• Insert Action Commands directly into registry keys

CORE\EXPLORER\MENUS\MEMBERS

CORE\EXPLORER\MENUS\ENTRIES

CORE\EXPLORER\MENUS\FILES

CORE\EXPLORER\MENUS\METAEXPLORE\TypeFilters

Programmatic Customization

• Proc REGISTRY

c:\temp\foo-actions.txt[CORE\EXPLORER\MENUS\MEMBERS\TABLE]"Foo 1"="VT %8b.%32b”"&Foo 2"="VT %8b.%32b”"10;&Foo 3"="VT %8b.%32b”"09;&Foo 4;100"="VT %8b.%32b”

SAS SessionProc REGISTRY IMPORT="c:\temp\foo-actions.txt";run;

Where’s my SAS Actions?

• In the SASHELP Registry!

• Copy them into your SASUSER registry

Proc REGISTRY USESASHELP STARTAT='CORE\EXPLORER\MENUS\MEMBERS\TABLE’ EXPORT='c:\temp\factory-table-actions.sasreg';

Proc REGISTRY IMPORT='c:\temp\factory-table-actions.sasreg';

I want to go home

• Remove customizations by deleting entries in the SASUSER registry

Proc REGISTRY STARTAT='CORE\EXPLORER\MENUS\MEMBERS\TABLE’ EXPORT='c:\temp\sasuser-table-actions.sasreg';

Proc REGISTRY UNINSTALL='c:\temp\sasuser-table-actions.sasreg';

• If a SASUSER branch is empty then SAS Explorer will use the SASHELP branch (home)

Automacros II

%macro action_members_table_A1 (lib,mem,pos3,pos4) /des='FS Browse';

/* browse a table using the likenamed screen stored * in sasuser.profile */

fsbrowse &lib..&mem sasuser.profile&lib..&mem..screen;

%mend;

• Programmatically realizable

Automacros II – Realizable?

• Read Metadata– DICTIONARY.CATALOGS– NAME is action_{branch}_{type} – DES is {text}

• Write import file and import[CORE\EXPLORER\MENUS\{branch}\{type}]“{DES}”=“%%{NAME}(%8b,%32b,%32b,%8b)”

Conclusion

• SAS Explorer is – essential– full featured– extensible

• Download a wide variety of actions from http://www.devenezia.com/downloads/sas/actions/main.php