1 / 11

Tips and Tricks

Tips and Tricks. Program Editor Macros – for PC SAS. Objectives. What are program editor macros? SAS code that is saved and available any time you open SAS When to use macros? Useful for templates Syntax that you rarely use How to create, save and re-use macros?

lorna
Télécharger la présentation

Tips and Tricks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tips and Tricks Program Editor Macros – for PC SAS

  2. Objectives • What are program editor macros? • SAS code that is saved and available any time you open SAS • When to use macros? • Useful for templates • Syntax that you rarely use • How to create, save and re-use macros? • All done in the program editor of the display manager

  3. Examples of PE macros • age=floor(yrdif(brth_dt,<date of interest>,'act/act')); • CASE WHEN SALES BETWEEN 0 AND 10000 THEN ’LOW’ WHEN SALES BETWEEN 10001 AND 15000 THEN ’AVG’ WHEN SALES BETWEEN 15001 AND 20000 THEN ’HIGH’ ELSE ’VERY HIGH’ END AS SALESCAT

  4. Steps for creating a macro • Type in your text into program editor window of display manager • Highlight the text and copy (ctrl-v) • In the display manager menu click ‘Tools’ and then • Click ‘Add Abbreviation’. Fill in the pop-up window and click ‘OK’. The “abbreviation” is the name of the macro • Paste the text that you copied into the window labeled, “Text to insert for abbreviation” • To use the macro: • ‘Tools’ -> ‘Keyboard Macros’ -> ‘Macros’. When you click ‘Macros’, a list of all your macros will appear and you choose the one you want. Or if you remember the name of your macro, type name into program editor window and it will populate. • Text will appear in display manager

  5. Once you store the macro, you can port the macro to any machine or share with others • Trivial example, but real PE macros can save tons of time • Use macros for: exporting to Excel • Importing from Excel • Program templates • Code that I use, but can’t remember the syntax • What will you use the PE macros for …

More Related