Code Monkey home page Code Monkey logo

macrocore's Introduction

Macro Core

Much quality. Many standards. The Macro Core library exists to save time and development effort! Herein ye shall find a veritable host of production quality SAS macros. These are a mix of tools, utilities, functions and code generators that are useful in the context of Application Development on the SAS platform. Contributions are welcomed.

Components

Base library

  • OS independent
  • Not metadata aware
  • No X command
  • Prefixes: mf, mp

Meta library

  • OS independent
  • Metadata aware
  • No X command
  • Prefixes: mm

xcmd library:

  • OS specific
  • Metadata aware
  • X command enabled
  • Prefixes: mw,mu,mx

Installation

First, download the repo to a location your SAS system can access. Then update your sasautos path to include the components you wish to have available,eg:

options insert=(sasautos="/your/path/macrocore/base");
options insert=(sasautos="/your/path/macrocore/meta");

The above can be done directly in your sas program, via an autoexec, or an initialisation program.

Alternatively - for quick access - simply run the following! This file contains all the macros.

filename mc url "https://raw.githubusercontent.com/Boemska/macrocore/master/macrocore.sas";
%inc mc;

Standards

File Properties

  • filenames much match macro names
  • filenames must be lowercase
  • macro names must be lowercase
  • one macro per file
  • prefixes:
    • mf for macro functions (can be used in open code).
    • mp for macro procedures (which generate sas code)
    • mm for metadata macros (interface with the metadata server).
    • mw for macros that only work in Windows (should work in ALL versions of windows)
    • mu for macros that only work in Unix type environments (should work in ALL types of unix environment)
    • mx for macros that use X command and will work in both windows and unix environments.
  • follow verb-noun convention
  • unix style line endings (lf)
  • individual lines should be no more than 80 characters long
  • UTF-8
  • no trailing white space
  • no trailing empty lines

Header Properties

The Macro Core documentation is created using doxygen. A full list of attributes can be found here but the following are most relevant:

  • file. This needs to be present in order to be recognised by doxygen.
  • brief. This is a short (one sentence) description of the macro.
  • details. A longer description, which can contain doxygen markdown.
  • param. Name of each input param followed by a description.
  • return. Explanation of what is returned by the macro.
  • version. The EARLIEST SAS version in which this macro is known to work.
  • author. Author name, contact details optional
  • copyright. Must be GNU GENERAL PUBLIC LICENSE v3.

All macros must be commented in the doxygen format, to enable the online documentation.

Coding Standards

  • Indentation = 2 spaces. No tabs!
  • Macro variables should not have the trailing dot (&var not &var.) unless necessary to prevent incorrect resolution
  • The closing %mend; should not contain the macro name.
  • All macros should be defined with brackets, even if no variables are needed - ie %macro x(); not %macro x;
  • Mandatory parameters should be positional, all optional parameters should be keyword (var=) style.
  • All dataset references to be 2 level (eg work.blah, not blah).
  • Avoid naming collisions! All macro variables should be local scope. Use system generated work tables where possible - eg data ; set sashelp.class; run; data &output; set &syslast; run;

General Notes

  • All macros should be compatible with SAS versions from support level B and above (so currently 9.2 and later). If an earlier version is not supported, then the macro should say as such in the header documentation, and exit gracefully (eg %if %sysevalf(&sysver<9.3) %then %return).

macrocore's People

Contributors

allanbowe avatar boomskats avatar maraja992 avatar senkastrahinovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

macrocore's Issues

Upgrade mm_createstp.sas to create Type 2 stored processes

Hi!
I have a question about the macro macrocore/meta/mm_createstp.sas.

The macro mentions this:

To upgrade this macro to work with type 2 (which can embed SAS code
and is compabitible with SAS from 9.3 onwards) then the UsageVersion should
change to 2000000 and the TextStore object updated.  The ComputeServer
reference will also be to ServerContext rather than LogicalServer.

This explanation is a bit vague.

Q: what exact actions should I perform to change the macro to create Type 2 stored processes?

  1. "switch 1000000 to 2000000" - got it;
  2. "TextStore object updated" - what does it mean?
  3. "The ComputeServer reference will also be to ServerContext rather than LogicalServer" - as far as I see it, all strings "ServerContext" in code should be replaced with "LogicalServer". Is that right?

Are the steps 1, 2, 3 enough?

I made steps 1 and 3, and it resulted in corrupt metadata for stored process. Now I cannot delete it :D

I would really appreciate if you mention some SAS docs which could help in understanding your code. I managed to find almost none.

Info on creating groups and groups associations

Hi all,
searching for some helpfoul macros, I noticed that in this collection there are macros to create stp, folders, libraries, ... but there are no macros to create groups or users, or ACT, and macros to associate groups to groups (while there is user to groups) or populate ACTs. Is there any reasons for that, or it's just because noone write those macros? I'm wondering if such a code could make any damage to metadata or something like it...
I.E. I would use something like this to create groups:

data USERS_TO_ADD;
    length _RC 8 GROUP_NAME $100 GROUP_URI $100;
    GROUP_NAME='TEST2';
    _RC=metadata_newobj('IdentityGroup', GROUP_URI, GROUP_NAME);
    _RC=metadata_setattr(GROUP_URI, "UsageVersion", "1000000");
    _RC=metadata_setattr(GROUP_URI, "PublicType", "UserGroup");
run;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.