List of RDS SAS Macros
From sasCommunity
This is a List of RDS SAS Macros, a part of Rapid Decision Support.
FUNCTION
- abs - ABS macro function similar to the ABS data step function. Returns the Absolute Value of an input string, or returns a missing value if the input is non-numeric.
- airy - AIRY macro function similar to the AIRY data step function. It returns the value of the AIRY function [Abramowitz, M. and Stegun, I (1964), Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables -- National Bureau of Standards Applied Mathematics Series #55, Washington, DC: U.S. Government Printing Office.]
- arcos - ARCOS macro function similar to the ARCOS data step function. Returns the ArcCosine or Inverse Cosine value.
- arsin - ARSIN macro function similar to the ARSIN data step function. returns the ArcSine or Inverse Sine value.
- atan - ATAN macro function similar to the ATAN data step function. It returns the ArcTangent or Inverse Tangent value.
- band - BAND macro function similar to the BAND data step function. It returns the BITWISE LOGICAL AND of two arguments. Accepts HEX values.
- betainv - BETAINV macro function similar to the BETAINV data step function. The BETAINV function returns the pth quantile from the beta distribution with shape parameters a and b. The probability that an observation from a beta distribution is less than or equal to the returned quantile is p. BETAINV is the inverse of the PROBBETA function.
- big - Returns the largest double-precision number
- blshift - BLSHIFT macro function similar to the BLSHIFT data step function. It returns the bitwise logical left shift of two arguments. It accepts HEX values.
- bnot - BNOT macro function similar to the BNOT data step function. It returns the bitwise logical NOT of an argument. It accepts HEX values.
- bor - BOR macro function similar to the BOR data step function. It returns the bitwise logical OR of two arguments.
- brshift - BRSHIFT macro function similar to the BRSHIFT data step function. It returns the bitwise logical right shift of two arguments and can accept HEX values.
- bxor - BXOR macro function similar to the BXOR data step function. It returns the bitwise logical EXCLUSIVE OR of two arguments and can accept HEX values.
- byte - BYTE macro function similar to the BYTE data step function. It returns one character in the ASCII or the EBCDIC collating sequence.
- cdf - CDF macro function similar to the CDF data step function. It computes cumulative distribution functions.
- ceil - CEIL macro function similar to the CEIL data step function. It returns the smallest integer that is greater than or equal to the argument.
- cexist - Verifies the existence of a SAS catalog or SAS catalog entry and returns a value
- character - Returns a list of all character variables in a given SAS data set
- cinv - CINV macro function similar to the CINV data step function. It returns a quantile from the chi-squared distribution.
- cnonct - CNONCT macro function similar to the CNONCT data step function. It returns the noncentrality parameter from a chi-squared distribution.
- collate - COLLATE macro function similar to the COLLATE data step function. It returns an ASCII or EBCDIC collating sequence character string.
- comb - COMB macro function similar to the COMB data step function. It computes the number of combinations of n elements taken r at a time and returns a value
- command - This macro returns to SAS the value of an operating system command. It only returns the FIRST LINE returned by the OS. Any additional lines returned after the first line are ignored.
- compound - COMPOUND macro function similar to the COMPOUND data step function. It returns values of compound interest calculations.
- constant - Computes some machine and mathematical constants and returns a value
- cos - COS macro function similar to the COS data step function. It returns the COSINE value.
- cosh - COSH macro function similar to the COSH data step function. It returns the Hyperbolic Cosine value.
- css - CSS macro function similar to the CSS data step function. It returns the Corrected Sum of Squares.
- currentpath - This macro function returns the full operating system path of the current path.
- cv - CV macro function similar to the CV data step function. It returns the coefficient of variation.
- daccdb - DACCDB macro function similar to the DACCDB data step function. It returns the accumulated declining balance depreciation.
- daccdbsl - DACCDBSLSL macro function similar to the DACCDBSL data step function. It returns the accumulated declining balance with conversion to a straight-line depreciation.
- daccsl - DACCSLSL macro function similar to the DACCSL data step function. It returns the accumulated straight-line depreciation.
- daccsyd - DACCSYDSL macro function similar to the DACCSYD data step function. It returns the accumulated sum-of-years-digits depreciation.
- dairy - DAIRY macro function similar to the DAIRY data step function. It returns the derivative of the airy function.
- data - This macro is used to make notes in the sas log more clear. It takes an input string (a dataset name) and checks the format. If it is a first level dataset name (i.e. TEMP) the macro turns the value into a second level dataset name (i.e. WORK.TEMP.) If the input string is already a two level it does not add the WORK. string in front of the value. In either case, it returns the value as uppercase text.
- datamem - This macro returns the physical file address of a given SAS data set
- datapath - This macro returns the physical file address of a given SAS data set
- date - Returns the current date as DATE9. format.
- datetime - This macro returns the current date and time in text format.
- depdb - DEPDB macro function similar to the DEPDB data step function. It returns the declining balance depreciation.
- depdbsl - DEPDBSL macro function similar to the DEPDBSL data step function. It returns the declining balance with conversion to a straight-line depreciation.
- depsl - DEPSL macro function similar to the DEPSL data step function. It returns the straight-line depreciation.
- depsyd - DEPSYD macro function similar to the DEPSYD data step function. It returns the sum-of-years-digits depreciation.
- dequote - DEQUOTE macro function similar to the DEQUOTE data step function. It removes quotation marks from a character value.
- digamma - DIGAMMA macro function similar to the DIGAMMA data step function. Returns the value of the DIGAMMA function.
- dospath - This macro returns a DOS FILE PATH from a given WINDOWS FILE PATH. The input file specification can be quoted or unquoted, but it will always return an unquoted string.
- e - Returns the natural number E
- erf - ERF macro function similar to the ERF data step function. It returns the value of the (normal) error function.
- erfc - ERFC macro function similar to the ERFC data step function. It returns the value of the complementary (normal) error function.
- euler - Returns the EULER constant
- exist - Verifies the existence of a SAS data library member
- exp - EXP macro function similar to the EXP data step function. It Returns the value of the exponential function.
- fact - FACT macro function similar to the FACT data step function. It returns the value of the factoral function.
- fexist - Verifies the existence of an external file associated with a fileref and returns a value
- filedt - This macro returns the current date and time in a text format that is suitable for a unique date-time stamp of a filename.
- fileexis - Verifies the existence of an external file by its physical name and returns a value
- fileexist - Verifies the existence of an external file by its physical name and returns a value
- fileread - Retrieves and returns the Nth record of a given file specification
- finv - FINV macro function similar to the FINV data step function. It returns a quantile from the F distribution.
- fipname - FIPNAME macro function similar to the FIPNAME data step function. It converts FIPS codes to uppercase state names.
- fipnamel - FIPNAMEL macro function similar to the FIPNAMEL data step function. It converts FIPS codes to mixed case state names.
- fipstate - FIPSTATE macro function similar to the FIPSTATE data step function. It converts FIPS codes to two-character postal codes.
- floor - FLOOR macro function similar to the FLOOR data step function. It returns the smallest integer that is less than or equal to the argument.
- fnonct - FNONCT macro function similar to the FNONCT data step function. It returns the value of the noncentrality parameter of an F distribution.
- fread - Retrieves and returns the Nth record of a given file declared by a FILENAME reference
- fuzz - FUZZ macro function similar to the FUZZ data step function. It returns the nearest integer if the argument is within 1E-12.
- gaminv - GAMINV macro function similar to the GAMINV data step function. It returns a quantile from the gamma distribution.
- gamma - GAMMA macro function similar to the GAMMA data step function. It returns the value of the gamma function.
- getvar - Returns the value of a variable for a specific observation in a given data set.
- getvarc - Returns the value of a character variable for a specific observation in a given data set.
- getvarn - Returns the value of a numeric variable for a specific observation in a given data set.
- ibessel - IBESSEL macro function similar to the IBESSEL data step function. It returns the value of the modified bessel function.
- indexc - INDEXC macro function similar to INDEXC data step function. It searches a character expression for specific characters. The INDEXC macro function searches source, from left to right, for the first occurrence of any character present in the excerpts and returns the position in source of that character. If none of the characters in EXCERPT are found in SOURCE, INDEXC returns a value of 0.
- indexvar - Returns the record number of the first occurence of a given string for a variable in a data set. Similar to the INDEX function except that checks complete variables across multiple records.
- indexw - INDEXW macro function similar to INDEXW data step function. It searches a character expression for a specified string as a word.
- int - INT macro function similar to the INT data step function
- intck - INTCK macro function similar to the INTCK data step function. It returns the integer number of time intervals in a given time span.
- intnx - INTNX macro function similar to the INTNX data step function. It advances a date, time, or datetime value by a given interval, and returns a date, time, or datetime value.
- intrr - INTRR macro function similar to the INTRR data step function. It returns the internal rate of return as a fraction.
- irr - IRR macro function similar to the IRR data step function. It returns the internal rate of return as a percentage.
- jbessel - JBESSEL macro function similar to the JBESSEL data step function. It returns the value of the bessel function.
- kurtosis - KURTOSIS macro function similar to the KURTOSIS data step function. It returns the kurtosis.
- lgamma - LGAMMA macro function similar to the LGAMMA data step function. It returns the natural logarithm of the Gamma function.
- libref - Verifies that a libref has been assigned and returns a value.
- log - LOG macro function similar to the LOG data step function. It returns the base 10 logarithm.
- log10 - LOG10 macro function similar to the LOG10 data step function. It returns the base 10 logarithm.
- log2 - LOG2 macro function similar to the LOG2 data step function. It returns the base 2 logarithm.
- logpdf - LOGPDF macro function similar to the LOGPDF data step function. It computes the logarithm of a probability density (mass) function.
- logsdf - LOGSDF macro function similar to the LOGSDF data step function. It computes the logarithm of a survival function.
- maceps - Returns the machine precision constant
- max - MAX macro function similar to the MAX data step function. It returns the largest value
- mean - MEAN macro function similar to the MEAN data step function. It returns the arithmetic mean.
- min - MIN macro function similar to the MIN data step function. It returns the smallest value
- mort - Returns amortization parameters
- mput - MPUT macro function similar to the PUT data step function. It returns a value using a specified format
- n - N macro function similar to the N data step function. It returns the number of the nonmissing numeric arguments.
- name - NAME macro function takes a given input string and returns a valid SAS Name of 32 characters or less.
- netpv - Returns the net present value as a fraction
- nmiss - NMISS macro function similar to the NMISS data step function. It returns the number of the missing numeric arguments.
- normal - NORMAL macro function similar to the NORMAL data step function. It returns a random variate from a normal distribution.
- npv - Returns the net present value with the rate expressed as a percentage
- numeric - Returns a list of all numeric variables in a given SAS data set
- obscnt - This macro returns the to the global macro variable var the number of observations in a dataset. It does not work on data views or tape datasets. If the macro cannot find a data set it will return the missing value.
- ordinal - Returns any specified order statistic
- pdf - PDF macro function similar to the PDF data step function. It computes probability density (mass) functions.
- perm - PERM macro function similar to the PERM data step function. It computes the number of permutations of n items taken r at a time and returns a value.
- pi - Returns the approximate value of PI
- poisson - POISSON macro function similar to the POISSON data step function. It returns the probability from a Poisson distribution.
- prefix - This macro adds the same prefix to a suffix list.
- probbeta - PROBBETA macro function similar to the PROBBETA data step function. It returns the probability from a beta distribution.
- probbnml - PROBBNML macro function similar to the PROBBNML data step function. Returns the probability from a binomial distribution.
- probbnrm - PROBBNRM macro function similar to the PROBBNRM data step function. It computes a probability from the bivariate normal distribution and returns a value
- probchi - PROBCHI macro function similar to the PROBCHI data step function. It returns the probability from a chi-squared distribution.
- probf - PROBF macro function similar to the PROBF data step function. It returns the probability from an F distribution.
- probgam - PROBGAM macro function similar to the PROBGAM data step function. It returns the probability from a gamma distribution.
- probhypr - PROBHYPR macro function similar to the PROBHYPR data step function. It returns the probability from a hypergeometric distribution.
- probit - PROBIT macro function similar to the PROBIT data step function. It returns a quantile from the standard normal distribution.
- probnegb - PROBNEGB macro function similar to the PROBNEGB data step function. It returns the probability from a negative binomial distribution.
- probnorm - PROBNORM macro function similar to the PROBNORM data step function. It returns the probability from the standard normal distribution.
- probt - PROBT macro function similar to the PROBT data step function. It returns the probability from a t distribution.
- put - MPUT macro function similar to the PUT data step function. It returns a value using a specified format
- ranbin - RANBIN macro function similar to the RANBIN data step function. It returns a random variate from a binomial distribution.
- ranbinary - RANBINARY macro function. It returns a random 1 or 0.
- rancau - RANCAU macro function similar to the RANCAU data step function. It returns a random variate from a Cauchy distribution
- ranexp - RANEXP macro function similar to the RANEXP data step function. It returns a random variate from an exponential distribution.
- rangam - RANGAM macro function similar to the RANGAM data step function. It returns a random variate from a gamma distribution
- range - RANGE macro function similar to the RANGE data step function. It returns the range of the values. The RANGE function returns the difference between the largest and the smallest of the nonmissing arguments.
- raninteger - raninteger macro function. It returns a uniformly random integer from 1 to MAX
- rank - RANK macro function similar to the RANK data step function. It returns the position of a character in the ASCII or EBCDIC collating sequence.
- rannor - RANNOR macro function similar to the RANNOR data step function. It Returns a random variate from a normal distribution
- ranpoi - RANPOI macro function similar to the RANPOI data step function. It Returns a random variate from a poisson distribution
- rantri - RANTRI macro function similar to the RANTRI data step function. It Returns a random variate from a triangular distribution
- ranuni - RANUNI macro function similar to the RANUNI data step function. It Returns a random variate from a uniform distribution
- reccnt - This macro returns the number of records in a given file
- repeat - REPEAT macro function similar to the REPEAT data step function. It repeats a character expression. The REPEAT function returns a string value consisting of the first argument repeated n times. Thus the first argument appears n+1 times in the result.
- reverse - REVERSE macro function similar to the REVERSE data step function. It reverses a character expression.
- round - ROUND macro function similar to the ROUND data step function. It rounds to the nearest round-off unit.
- saving - SAVING macro function similar to the SAVING data step function. It returns values of saving rate interest calculations.
- sdf - SDF macro function similar to the SDF data step function. It computes a survival function.
- sign - SIGN macro function similar to the SIGN data step function
- sin - SIN macro function similar to the SIN data step function. It returns the value of the triginometric SINE function.
- sinh - SINH macro function similar to the SINH data step function. It returns the value of the Hyperbolic Sine function.
- skewness - SKEWNESS macro function similar to the SKEWNESS data step function. It returns theskewness.
- sleep - SLEEP macro function Suspends execution of a SAS DATA step for a specified number of seconds and returns that number.
- small - Returns the smallest double-precision number
- sortlist - This macro returns a string of words in sorted order
- sqrt - SQRT macro function similar to the SQRT data step function
- sqrtbig - Returns the square root of the largest double-precision number
- sqrtmaceps - Returns the square root of the machine precision constant
- sqrtsmall - Returns the square root of the smallest double-precision number
- std - STD macro function similar to the STD data step function. It returns the standard deviation
- stderr - STDERR macro function similar to the STDERR data step function. It returns the standard error of the mean.
- stfips - Converts state postal codes to FIPS state codes
- stname - Converts state postal codes to uppercase state names
- stnamel - Converts state postal codes to mixed case state names
- string - This macro returns a string of words in the form pre1 pre2 pre3 ...
- suffix - This macro adds the same suffix to a prefix list.
- sum - SUM macro function similar to the SUM data step function. It returns the sum of the nonmissing arguments.
- sysmsg - Returns the text of error messages or warning messages from the last data set or external file function execution.
- tan - TAN macro function similar to the TAN data step function. It returns the value of the triginometric tangent function.
- tanh - TANH macro function similar to the TANH data step function. It returns the value of the Hyperbolic Tangent function.
- time - Returns the current time of day in format TIME.
- today - Returns the current date as DATE9. format.
- translate - TRANSLATE macro function similar to TRANSLATE data step function
- tranwrd - Tranwrd macro function similar to tranwrd data step function. It replaces or removes all occurrences of a word in a character string.
- trigamma - TRIGAMMA macro function similar to the TRIGAMMA data step function. It returns the value of the trigamma function.
- uniform - UNIFORM macro function similar to the UNIFORM data step function. It returns a random variate from a uniform distribution.
- unique - This macro returns a list of unique tokens from a given list of tokens. All values are returned and all comparisons are made in UPPERCASE.
- uss - USS macro function similar to the USS data step function. It returns the uncorrected sum of squares.
- var - VAR macro function similar to the VAR data step function. It returns the variance.
- varcnt - This macro returns the number of variables in a SAS dataset.
- varfmt - Returns the format assigned to a SAS data set variable.
- varinfmt - Returns the informat assigned to a SAS data set variable.
- varlabel - Returns the label assigned to a SAS data set variable.
- varlen - Returns the length assigned to a SAS data set variable.
- varlist - Returns a list of all variables in a given SAS data set
- varnum - Returns the position assigned to a SAS data set variable or 0 if the variable does not exist.
- vartype - Returns the type assigned to a SAS data set variable.
- wakeup - WAKEUP macro function specifies the time the SAS System begins execution.
- wordcnt - This macro returns the number of words in the input string.
- zipfips - Converts ZIP codes to FIPS state codes
- zipname - Converts ZIP codes to uppercase state names
- zipnamel - Converts ZIP codes to mixed case state names
- zipstate - Converts ZIP codes to state postal codes
MACRO
- bigsort - This macro breaks a data set into smaller data sets, sorts those smaller data sets, and then combines them back together in order. It is designed for sorting a very large dataset more efficiently by using less sort space.
- breakout -
This macro is designed to create multiple SAS data sets from one given data set or view. Each data set contains the unique records that apply to a specific variable. For example, if the value of VAR is COLOR, then each output data set would contain all o f the records for each one unique value of color. All of the records for BLUE would be in one data set, RED in another data set, GREEN in a third data set.
- checkall - This macro prints a check-all-that-apply report on a special kind of check-all-that-apply variable
- checkrec - This macro prints a sample of the first records of an input file
- compare - This macro is used to compare multiple datasets and check for any similar variable names. It also does a comparison of the number of observations and prints a list of discrepencies of variable names and variable types.
- contents - This macro runs a proc contents and prints the first 20 records of the input dataset or datasets. The number of observations can be overridden to a specific value. The macro can also add a title to your output.
- datanote - This macro prints a standard SAS note about the contents of a SAS dataset into the log.
- decrypt - This macro decrypts a given encrypted file
- dictionary - This macro creates an html-based data dictionary of given SAS libraries
- directory - This macro reads the files in a drive including sub-directories and writes the results out to a standard SAS dataset.
- doubles - This macro is designed to check for exact duplicate and/or near duplicate observations in a SAS dataset. It generates a printout of near duplicates for further manual examination and notes in the log changes made to the output dataset.
- encrypt - This macro creates an encrypted file from a given input file.
- exception - This macro creates an exception report for a field in a given data set based on a given format.
- filecat - This macro concatenates two files together and writes them out to a third output file
- filein - This macro reads in a quoted comma delimited file to a SAS dataset
- filenote - This macro creates a standard SAS File Creation Note.
- fileout - This macro writes out a quoted comma delimited file from a SAS dataset
- filescan - This macro scans an input file for occurences of all variable names in a given SAS dataset. It is designed to scan a SAS program to determine if there are any variables in a SAS dataset that are not used by that program. If so, the macro prints a report. If not, a note is put in the log.
- findfile - This macro finds a file somewhere in a given drive or folder
- format - This macro reads a cntlin dataset into a format catalog. It will work for one START variable and multiple LABEL variables. The name of each format corresponds to the name of the variable. If it is a character START variable, a dollar sign is automatically placed in front of the variable name.
- freqrept - This macro compiles a frequency report with multiple variables on one report.
- gettemp - This macro creates a one-record SAS data containing temperature data for a given zip code.
- good2bad - This macro creates trashed, messed-up data based on the values of an input data set. It is useful in creating, or at least creating the beginnings of, a testing SAS data set.
- html2txt - This macro takes an html file and writes out the text to another file.
- iefbr14 - This macro takes an infinite amount of input and has absoloutely no output. WHY? Because there may be a condition sometime to always have a macro called, but the macro name could be conditional and the result should be nothing. If that case ever arises, use this one. It gets its name from the MVS JCL executable IEFBR14.
- info - This macro creates an INFO note
- lfoot - Creates a left-justified footnote statement
- linesofcode - This macro creates an administrative report on all SAS programs in a given PC file folder
- logreader - Creates a report and output data set of WARNINGS and ERRORS in a given SAS log file.
- maketitle - This macro creates titles and footnotes from a title and footnote data set
- manifest - This macro prints all values of any variable. It is designed to fit as many columns of that variable on a single page.
- mem - This macro creates a SAS data set containing the OS memory for the Windows Operating System.
- nextdata - This macro returns the next available new data set in the given libname (i.e. WORK.DATAn)
- nextlib - This macro returns the next available new data set in the given libname (i.e. WORK.DATAn)
- out - This macro returns the next available new data set in the given libname (i.e. WORK.DATAn)
- outlier - This macro creates a second output data set from an input data set and screens the data (removes records) based on removing any outlier records that occur outside a given number of standard deviations from the mean. The outlier screen can be passed through a number of times.
- pareto - This macro creates a Pareto Chart
- pgmtest - Test and re-test a SAS program and report on the average run time of each procedure, data step, and RDS Macro.
- popopts - This macro restores the SAS System Options from a SAS options holding SAS data set
- poppageno - This macro creates creates SAS data set containing the current page number.
- poptitle - This macro creates titles and footnotes from a title and footnote data set
- pushopts - This macro pushes the options to a holding SAS data set
- pushpageno - This macro creates creates SAS data set containing the current page number.
- pushtitle - This macro pushes the titles and footnotes to a holding SAS data set
- sample - This macro will create a random sample of a SAS dataset.
- scramble - This macro is used to generate a random password, compress a file protected by that password, and send that file via e-mail followed by another e-mail containing the password.
- shuffle - This macro randomly shuffles the records of a SAS data set
- slide - This macro creates a slide-bar chart to compare the results of individual observations of a SAS dataset.
- sortall - This macro sorts all input datasets by the same variables.
- stemleaf - This macro creates a standard STEM-LEAF diagram
- sysvars - This macro gets all SYSTEM variables and writes to a SAS data set
- taghelp - This macro takes a tag-style file (such as HTML or XML) and creates a new file with one line for each complete tag and a separate line for the contents held within the tag. It is used to read complex HTML and XML files and is helpful for debugging.
- templib - This macro creates a temporary libname file in a subdirectory of the WORK data library
- timenote - This macro is designed to record the run time of another macro
- trimfile - This macro trims all trailing blanks on a file and compresses blanks down to one blank only (see the COMPBL function in BASE SAS). The designed application is to trim/compress *.html files.
- univ - This macro completes a statistical analysis of many variables and prints the output on one page. Basically, it is a PROC UNIVARIATE with an output that looks like PROC MEANS.
- wordwrap - This macro reads in a file and removes hard carriage returns inside of paragraphs. A paragraph break must originally be noted as a blank line.
METHOD
- _age - This macro is designed to function INSIDE a SAS data step. It will calculate the age in years given a start and end date.
- _c2f - This macro is designed to function INSIDE a SAS data step. It will convert Degrees Celsius to Degrees Fahrenheit
- _city - This macro is designed to function INSIDE a SAS data step. It will take a standard City_state_ZIP variable and pull out the CITY
- _f2c - This macro is designed to function INSIDE a SAS data step. It will convert Degrees Fahrenheit to Degrees Celsius
- _pctchange - This macro is designed to function INSIDE a SAS data step. It will calculate the percent change between two points.
- _propername - This macro is designed to function INSIDE a SAS data step. It will transform the input variable values to mixed case for proper nouns. It is not 100% accurate, as macgyver becomes MacGyver, but mack will become MacK. Make edits to meet your needs based on your database.
- _state - This macro is designed to function INSIDE a SAS data step. It will take a standard City_state_ZIP variable and pull out the STATE
- _zip - This macro is designed to function INSIDE a SAS data step. It will take a standard City_state_ZIP variable and pull out the zip code