Skip to content

SamSvet/sas_macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

SAS Macro

Here I have collected a set of utility macros that I have been using for creating ETL procedures. Some of them turned out to be useful SAS_FileUploader project. You can find an example of using macros in the folder example.

Installation

Download macro folder to somewhere under your SAS system.

Then update your sasautos path to have macros available,eg:

options mautosource insert=(sasautos="/your/path/to/macro");

Alternatively you can include whole folder without updating any SAS options:

%include "/your/path/to/macro/*";

Details

Datastep macro Macros whose name starts with do_ belong to datastep macros, i.e. generate code and apply inside data step. do_setflag.sas, do_setflag_array.sas, do_sametype.sas I used in a SAS_FileUploader project.

Inline macro Some macros return a value and might be used inside sas macro statements, so they are called inline.

data varlist;
length varlist $1024;
varlist="%varlist(sashelp.class)"; output;
varlist="%varlist(sashelp.cars)"; output;
run;
%put %sort(12 3 7 9 4);

This group includes varlist.sas, attrntype.sas, sort.sas, intersection.sas and some others.

Resolve SQL macro resolve_sql.sas allows you to execute SQL-templates inside proc sql. SQl-template is external file, e.g. select_class.txt, which contains DDL, DML commands. You can see usage example here resolve_sql_eg.sas.

Error control macro seterr.sas, clearerr.sas, checkerr.sas is used to control errors in sas programs.

All these macros make the code more declarative and therefore more readable and reusable.

About

This is a set of utility sas macros

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages