Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
base Directory Reference

Regular Base SAS Macros.

More...

Detailed Description

These macros have the following attributes:

  OS independent
  Not metadata aware
  No X command
  Prefixes:  _mf_, _mp_

Macros starting mf_ are macro functions and can be used in assignment statements. Those starting mp_ are macro procedures, which generate SAS statements, and must therefore be applied accordingly.

Files

 mf_abort.sas
 Abort, ungracefully.
 
 mf_dedup.sas
 de-duplicates a macro string
 
 mf_deletefile.sas
 Deletes a physical file, if it exists.
 
 mf_existds.sas
 Checks whether a dataset OR a view exists.
 
 mf_existfeature.sas
 Checks whether a feature exists.
 
 mf_existfileref.sas
 Checks whether a fileref exists.
 
 mf_existfunction.sas
 Checks if a function exists.
 
 mf_existvar.sas
 Checks if a variable exists in a data set.
 
 mf_existvarlist.sas
 Checks if a set of variables ALL exist in a data set.
 
 mf_fmtdttm.sas
 Returns E8601DT26.6 if compatible else DATETIME19.3.
 
 mf_getapploc.sas
 Returns the appLoc from the _program variable.
 
 mf_getattrc.sas
 Returns a character attribute of a dataset.
 
 mf_getattrn.sas
 Returns a numeric attribute of a dataset.
 
 mf_getengine.sas
 Returns the engine type of a SAS library.
 
 mf_getfilesize.sas
 Returns the size of a file in bytes.
 
 mf_getfmtlist.sas
 Returns a distinct list of formats from a table.
 
 mf_getfmtname.sas
 Extracts a format name from a fully defined format.
 
 mf_getgitbranch.sas
 Retrieves the current branch from a local GIT repo.
 
 mf_getkeyvalue.sas
 retrieves a key value pair from a control dataset
 
 mf_getplatform.sas
 Returns platform specific variables.
 
 mf_getquotedstr.sas
 Adds custom quotes / delimiters to a delimited string.
 
 mf_getschema.sas
 Returns the database schema of a SAS library.
 
 mf_getuniquefileref.sas
 Assigns and returns an unused fileref.
 
 mf_getuniquelibref.sas
 Returns an unused libref.
 
 mf_getuniquename.sas
 Returns a shortened (32 char) GUID as a valid SAS name.
 
 mf_getuser.sas
 Returns a userid according to session context.
 
 mf_getvalue.sas
 Retrieves a value from a dataset. If no filter supplied, then first record is used.
 
 mf_getvarcount.sas
 Returns number of variables in a dataset.
 
 mf_getvarformat.sas
 Returns the format of a variable.
 
 mf_getvarlen.sas
 Returns the length of a variable.
 
 mf_getvarlist.sas
 Returns dataset variable list direct from header.
 
 mf_getvarnum.sas
 Returns the position of a variable in dataset (varnum attribute).
 
 mf_getvartype.sas
 Returns variable type - Character (C) or Numeric (N)
 
 mf_getxengine.sas
 Returns the engine type of a SAS fileref.
 
 mf_increment.sas
 Increments a macro variable.
 
 mf_isblank.sas
 Checks whether a macro variable is empty (blank)
 
 mf_isdir.sas
 Checks whether a path is a valid directory.
 
 mf_isint.sas
 Returns 1 if the variable contains only digits 0-9, else 0.
 
 mf_islibds.sas
 Checks whether a string follows correct library.dataset format.
 
 mf_loc.sas
 Returns physical location of various SAS items.
 
 mf_mkdir.sas
 Creates a directory, including any intermediate directories.
 
 mf_mval.sas
 Returns a macro variable value if the variable exists.
 
 mf_nobs.sas
 Returns number of logical (undeleted) observations.
 
 mf_readfile.sas
 Reads the first line of a file using pure macro.
 
 mf_trimstr.sas
 Removes character(s) from the end, if they exist.
 
 mf_uid.sas
 Creates a unique ID based on system time in friendly format.
 
 mf_verifymacvars.sas
 Checks if a set of macro variables exist AND contain values.
 
 mf_wordsinstr1andstr2.sas
 Returns words that are in both string 1 and string 2.
 
 mf_wordsinstr1butnotstr2.sas
 Returns words that are in string 1 but not in string 2.
 
 mf_writefile.sas
 Creates a text file using pure macro.
 
 mp_abort.sas
 abort gracefully according to context
 
 mp_aligndecimal.sas
 Apply leading blanks to align numbers vertically in a char variable.
 
 mp_appendfile.sas
 Append (concatenate) two or more files.
 
 mp_applyformats.sas
 Apply a set of formats to a table.
 
 mp_assert.sas
 Generic assertion.
 
 mp_assertcols.sas
 Asserts the existence (or not) of columns.
 
 mp_assertcolvals.sas
 Asserts the values in a column.
 
 mp_assertdsobs.sas
 Asserts the number of observations in a dataset.
 
 mp_assertscope.sas
 Used to capture scope leakage of macro variables.
 
 mp_base64copy.sas
 Convert a file to/from base64 format.
 
 mp_binarycopy.sas
 Copy any file using binary input / output streams.
 
 mp_chop.sas
 Splits a file of ANY SIZE by reference to a search string.
 
 mp_cleancsv.sas
 Fixes embedded cr / lf / crlf in CSV.
 
 mp_cntlout.sas
 Creates a cntlout dataset in a consistent format.
 
 mp_copyfolder.sas
 A macro to recursively copy a directory.
 
 mp_coretable.sas
 Create the permanent Core tables.
 
 mp_createconstraints.sas
 Creates constraints.
 
 mp_createwebservice.sas
 Create a web service in SAS 9, Viya or SASjs Server (legacy)
 
 mp_csv2ds.sas
 Efficient import of arbitrary CSV using a dataset as template.
 
 mp_deleteconstraints.sas
 Delete constraionts.
 
 mp_deletefolder.sas
 A macro to delete a directory.
 
 mp_dictionary.sas
 Creates a portal (libref) into the SQL Dictionary Views.
 
 mp_dirlist.sas
 Returns all files and subdirectories within a specified parent.
 
 mp_distinctfmtvalues.sas
 Creates a dataset containing distinct formatted values.
 
 mp_dropmembers.sas
 Drops tables / views (if they exist) without warnings in the log.
 
 mp_ds2cards.sas
 Create a CARDS file from a SAS dataset.
 
 mp_ds2csv.sas
 Export a dataset to a CSV file WITH leading blanks.
 
 mp_ds2ddl.sas
 Fetches DDL for a specific table.
 
 mp_ds2fmtds.sas
 Converts every value in a dataset to formatted value.
 
 mp_ds2inserts.sas
 Export a dataset to SQL insert statements.
 
 mp_ds2md.sas
 Create a Markdown Table from a dataset.
 
 mp_ds2squeeze.sas
 Create a smaller version of a dataset, without data loss.
 
 mp_dsmeta.sas
 Export dataset metadata to a single output table.
 
 mp_filtercheck.sas
 Checks an input filter table for validity.
 
 mp_filtergenerate.sas
 Generates a filter clause from an input table, to a fileref.
 
 mp_filterstore.sas
 Checks & Stores an input filter table and returns the Filter Key.
 
 mp_filtervalidate.sas
 Checks a generated filter query for validity.
 
 mp_getcols.sas
 Creates a dataset with column metadata.
 
 mp_getconstraints.sas
 Get constraint details at column level.
 
 mp_getdbml.sas
 Extract DBML from SAS Libraries.
 
 mp_getddl.sas
 Extract DDL in various formats, by table or library.
 
 mp_getformats.sas
 Export format definitions.
 
 mp_getmaxvarlengths.sas
 Scans a dataset to find the max length of the variable values.
 
 mp_getpk.sas
 Extract the primary key fields from a table or library.
 
 mp_gitadd.sas
 Stages files in a GIT repo.
 
 mp_gitlog.sas
 Creates a dataset with the commit history of a local repository.
 
 mp_gitreleaseinfo.sas
 Pulls latest release info from a GIT repository.
 
 mp_gitstatus.sas
 Creates a dataset with the output from GIT_STATUS()
 
 mp_gsubfile.sas
 Performs a text substitution on a file.
 
 mp_guesspk.sas
 Guess the primary key of a table.
 
 mp_hashdataset.sas
 Returns a unique hash for a dataset.
 
 mp_hashdirectory.sas
 Returns a unique hash for each file in a directory.
 
 mp_include.sas
 Performs a wrapped %include.
 
 mp_init.sas
 Initialise session with useful settings and variables.
 
 mp_jsonout.sas
 Writes JSON in SASjs format to a fileref.
 
 mp_lib2cards.sas
 Convert all library members to CARDS files.
 
 mp_lib2inserts.sas
 Convert all data in a library to SQL insert statements.
 
 mp_loadformat.sas
 Loads a format catalog from a staging dataset.
 
 mp_lockanytable.sas
 Mechanism for locking tables to prevent parallel modifications.
 
 mp_lockfilecheck.sas
 Aborts if a SAS lock file is in place, or if one cannot be applied.
 
 mp_makedata.sas
 Create sample data based on the structure of an empty table.
 
 mp_md5.sas
 Generates an md5 expression for hashing a set of variables.
 
 mp_perflog.sas
 Logs a message in a dataset every time it is invoked.
 
 mp_prevobs.sas
 Enables previous observations to be re-instated.
 
 mp_recursivejoin.sas
 Returns all children from a hierarchy table for a specified parent.
 
 mp_replace.sas
 Performs a text substitution on a file.
 
 mp_reseterror.sas
 Reset when an err condition occurs.
 
 mp_resetoption.sas
 Reset an option to original value.
 
 mp_retainedkey.sas
 Generate and apply retained key values to a staging table.
 
 mp_runddl.sas
 An opinionated way to execute DDL files in SAS.
 
 mp_searchcols.sas
 Searches all columns in a library.
 
 mp_searchdata.sas
 Searches all data in a library.
 
 mp_setkeyvalue.sas
 Logs a key value pair a control dataset.
 
 mp_sortinplace.sas
 Sorts a SAS dataset in place, preserving constraints.
 
 mp_stackdiffs.sas
 Prepares an audit table for stacking (re-applying) the changes.
 
 mp_storediffs.sas
 Converts deletes/changes/appends into a single audit table.
 
 mp_stprequests.sas
 Capture session start / finish times and request details.
 
 mp_streamfile.sas
 Streams a file to _webout according to content type.
 
 mp_stripdiffs.sas
 Generates a stage dataset to revert diffs tracked in an audit table.
 
 mp_testjob.sas
 Runs arbitrary code for a specified amount of time.
 
 mp_testservice.sas
 To be deprecated. Will execute a SASjs web service on SAS 9 or Viya.
 
 mp_testwritespeedlibrary.sas
 Tests the write speed of a new table in a SAS library.
 
 mp_tree.sas
 Recursively scans a directory tree to get all subfolders and content.
 
 mp_unzip.sas
 Unzips a zip file.
 
 mp_updatevarlength.sas
 Change the length of a variable.
 
 mp_validatecol.sas
 Used to validate variables in a dataset.
 
 mp_wait4file.sas
 Wait until a file arrives before continuing execution.
 
 mp_webin.sas
 Fix the _WEBIN variables provided to SAS web services.
 
 mp_zip.sas
 Creates a zip file.