Macro List

(shown in alphabetical order)

NOTE: Do not download macros from a browser window because the browser might change some of the text where it encounters ampersands (very common in the macro code). Either download from the browser "Source" window or use the download page to download the zips.

Shortcut to utility macros

Avoiding "collisions" with Spectre macros

Note that timestamps shown below may be out of date by a month. Correct timestamps are shown on the updates page.

List of Clinical macros

Feb 19 18:33 aetab.sas
Jul 30  2007 allocr.sas
Jul 30  2007 allocw.sas
Jun 13 22:30 blflag.sas
Feb 19 18:40 comblvls.sas
Mar 15 07:26 dosemerge.sas
Feb 19 18:42 freqlvls.sas
Dec  5  2011 labncfb.sas
Mar 15 07:29 locf.sas
Mar 15 07:29 nodata.sas
Feb 19 18:37 npctpvals.sas
Feb 19 18:34 npcttab.sas
Mar 15 07:29 popfmt.sas
Feb 19 18:41 prntlvls.sas
Feb 19 18:31 rgpp.sas
Feb 19 18:43 trnslvls.sas
Apr 21 10:40 unicat2word.sas
Feb 19 18:40 unicatrep.sas
Apr 21 10:39 unimap.sas
Feb 19 18:37 unipvals.sas
Apr 21 11:00 unistatlabel.sas
Feb 19 18:35 unistats.sas

Clinical macro purposes

Index of members in this directory with standard headers
========================================================
(this list was generated by the crindex script)

aetab.sas          - To create a multi-level AE table of counts and percentages

                     Usage: %aetab(ae3,msoc mhlgt mhlt mpt aeint)

                     %aetab(dsin=ae3,varlist=msoc mhlgt mhlt mpt aeint)

                     %aetab(dsin=ae3,varlist=msoc mhlgt mhlt mpt aeint,trtalign=center,
                     colw=48,trtlabel="_Treatment Arms_" " ",total=yes,events=yes,
                     alllowlvl=yes,alllowwhere=lvl5 ne ".",lowinfmt=int.);

allocr.sas         - Spectre (Clinical) example macro to allocate data libraries and
                     formats in read mode.

                     Usage: %allocr
 

allocw.sas         - Spectre (Clinical) example macro to allocate data libraries and
                     formats in write mode.

                     Usage: %allocw

blflag.sas         - Clinical reporting utility macro to flag baseline observations.

                     Usage: %blflag(dsin=test,dsout=flagged,blflagvar=blf,blset="Y",
                            trtstartvar=start,tmptvar=tmpt,groupbyvars=pat labnm,
                            valvar=val);
 

comblvls.sas       - To combine levels data from the %freqlvls macro

                     Usage: %comblvls(dsin=myds,lvls=5,varlen=256,colw=50)

dosemerge.sas      - Clinical reporting macro to merge dose in with date

                     Usage: 
 

freqlvls.sas       - To give frequency counts by category and sub-category levels

                     Usage: %freqlvls(sashelp.cars,make type model,trtvar=origin,
                     trttot="ALL");
                     data cars;
                     length pat $ 3;
                     set sashelp.cars;
                     pat=model;
                     run;
                     %freqlvls(cars,make type model,trtvar=origin,trttot="ALL",
                     nodupvars=pat);

labncfb.sas        - To produce a table of lab (normalized) change from baseline

                     Usage: options nocenter nobyline;
                     title "Functional Group: #byval(labgrpx)";

                     %labncfb(inlab=lab,inpopu=popu,popu=TS,intrt=gentrt,analno=3,
                     descstats=N Min Mean SD Max,innorm=labref(where=(type="RR")),
                     ingrp=labref(where=(type="LG")));

locf.sas           - Clinical reporting macro to perform "Last Observation Carried
                     Forward" processing.

                     Usage: 
 

nodata.sas         - To produce a "No Data" report

                     Usage: %if not %nobs(dset) %then %do;
                     %nodata
                     %goto skip;
                     %end;

npctpvals.sas      - Clinical reporting macro that calculates p-values for the
                     %npcttab macro.

                     Usage: %npctpvals(dsin=data1,byvars=byvar1 byvar2,trtvar=trtgrp,
                     respvar=resp,countvar=count,pvalstr=TRT9999)
 

npcttab.sas        - Clinical reporting macro to produce tables showing "n", the
                     percentage and optionally, the number of events.

                     Usage: See tutorial with demonstrations on the Spectre web site. After
                     completing the tutorial you will be able to learn more about the
                     capabilities of this macro by reading this header.
 

popfmt.sas         - Clinical reporting macro to create a treatment format that is the
                     same as an existing format but with the (N=xxx) at the end.

                     Usage: %popfmt(stat.acct(where=(xxx=1 and &_pop_.cd=1)),trtgroup)
 

prntlvls.sas       - To print data created by the %freqlvls and %comblvls macros

                     Usage: %prntlvls(dsin=myds,lvls=5,trtvars=TRT1 TRT2,colw=40)

rgpp.sas           - Create html graphical patient profiles

                     Usage: %rgpp

trnslvls.sas       - To transpose levels data from the %freqlvls macro

                     Usage: %trnslvls(dsin=myds,lvls=5,trtvar=trtarm,trtord=99,prefix=TRT,
                     dsout=mydsout,plugwith="  0 (  0.0)   0")
                     %trnslvls(dsin=both,dsout=tranboth,var=str,trtvar=tpatt,
                     trtord="XXX",alllowlvl=yes,alllowwhere=lvl5 ne ".",
                     plugwith="   0 (  0.0)     0",lvls=5,lvl5infmt=int.,
                     lvl1anylbl="Patients with any AE")

unicat2word.sas    - Clinical reporting macro to produce a Word-style cell table
                     from the dataset output from the %unistats macro of treatment-
                     transposed categories counts and statistics.

                     Usage: %unicat2word(dsin=_unitran,dest=print,dlim=';')
 

unicatrep.sas      - Clinical reporting macro to produce a report from the dataset
                     output from the %unistats macro of treatment-transposed
                     categories counts and statistics.

                     Usage: %unicatrep(dsin=_unitran)
 

unimap.sas         - Function-style clinical reporting macro to map proc univariate
                     labels to the actual stats keyword names.

                     Usage: %let stats=%unimap(&labels);

unipvals.sas       - Clinical reporting macro to calculate statistics values and
                     p-values for the %unistats macro.

                     Usage: %unipvals(dsin=means,dsout=out,trtvar=tmt,respvar=val,type=N)
 

unistatlabel.sas   - To replace _statlabel values in the %unistats output dataset

                     Usage: N/A

unistats.sas       - Clinical reporting macro to calculate proc univariate
                     statistics and category counts with percentages with optional
                     statistics added and by default to print a report.

                     Usage: See tutorial with demonstrations on the Spectre web site. After
                     completing the tutorial you will be able to learn more about the
                     capabilities of this macro by reading this header.

List of System macros

May  8  2011 allocr.sas
May  8  2011 allocw.sas
Oct 12  2009 autoexec.sas
May  8  2011 closerep.sas
May  8  2011 crprotds.sas
May  8  2011 crtitlesds.sas
May  8  2011 ctitlepgmrk.sas
May  8  2011 jobinfo.sas
May  8  2011 layout2lsps.sas
May  8  2011 openrep.sas
May  8  2011 pagexofy.sas
May  8  2011 proginfo.sas
May  8  2011 protinfo.sas
May  8  2011 titlegen.sas
May  8  2011 titles.sas
May  8  2011 xytitles.sas

System macro purposes

Index of members in this directory with standard headers
========================================================
(this list was generated by the crindex script)

allocr.sas         - Spectre (Clinical) example macro to allocate data libraries and
                     formats in read mode.

                     Usage: %allocr
 

allocw.sas         - Spectre (Clinical) example macro to allocate data libraries and
                     formats in write mode.

                     Usage: %allocw
 

closerep.sas       - Spectre (Clinical) macro to close the temporary file created
                     by the %openrep macro for redirected sas output and copy to a
                     final output file with page number labels added.

                     Usage: Should be used with the %titles and %openrep macros as below.

                     %allocr
                     %titles
                     %openrep
                     <reporting code>
                     %closerep
 

crprotds.sas       - Spectre (Clinical) macro to create a protocol dataset from a
                     protocol details flat file.

                     Usage: %crprotds(flatfile,der.study)
 

crtitlesds.sas     - Spectre (Clinical) macro to create a titles dataset from a
                     titles flat file.

                     Usage: %crtitlesds(flatfile,der.titles)
 

ctitlepgmrk.sas    - Spectre (Clinical) macro to create a centered top title with a
                     right-most "FF"x page mark.

                     Usage: %ctitlepgmrk("centred title")
 

jobinfo.sas        - Spectre (Clinical) macro to store important job information in
                     global macro variables.

                     Usage: %jobinfo
 

layout2lsps.sas    - Spectre (Clinical) macro to calculate sas linesize and pagesize
                     values based on paper type, margins and layout.

                     Usage: %layout2lsps(lmargin=1.0,rmargin=0.75,tmargin=1.0,bmargin=1.0,
                     paper=A4,layout=L10);

openrep.sas        - Spectre (Clinical) macro to redirect print output to a
                     temporary file.

                    Usage: Should be used with the %titles and %closerep macros as below.

                     %allocr
                     %titles
                     %openrep
                     <reporting code>
                     %closerep
 

pagexofy.sas       - Spectre (Clinical) macro to add "Page x of Y" labels where
                     the 'FF'x character is found and to make other special
                     character substitutions.

                     Usage: %pagexofy(myfile.lst)
                     %pagexofy(myfile.lst,style="Page x of Y")
                     %pagexofy(myfile.lst,style="Seite x von Y")
                     %pagexofy(myfile.lst,style="(PAGE X OF Y)")
                     %pagexofy(myfile.lst,style="SEITE x")
                     %pagexofy(myfile.lst,style="[SEITE x]"

proginfo.sas       - Spectre (Clinical) macro to store important program information
                     in global macro variables.

                     Usage: %proginfo
 

protinfo.sas       - Spectre (Clinical) macro to store important protocol information
                     in global macro variables.

                     Usage: %protinfo
 

titlegen.sas       - Spectre (Clinical) macro to generate titles and footnotes from a
                     dataset of the style created by the %crtitlesds macro.

                     Usage: %titlegen(dsname)
 

titles.sas         - Spectre (Clinical) macro to create the titles and footnotes for
                     a standard report.

                     Usage: Should be used with the %openrep and %closerep macros as below.

                     %allocr
                     %titles
                     %openrep
                     <reporting code>
                     %closerep
 

xytitles.sas       - Spectre (Clinical) macro to finish creating the header lines
                     for the imaginary XenuYama pharmaceutical company style.

                     Usage: Must be called from within the %titles macro and must not be
                     used standalone.

List of Utility macros

There are more than 200 utility macros you can link to below. I'd advise you to not only treat these utility macros as a collection to help you do your sas work but to regard them as a complete system in itself. Once you know what the macros here can do then they can help you create complex applications on your own. The sum of the whole is greater than the sum of the parts. Knowing all the tools it puts at your disposal allows it to act as a sort of development environment and the utility macros like a meta language for creating applications. If you are here looking for "something" then consider taking the time to see the scope of what is here with a view of seeing how you might be able to use the macros to create whole applications at some time in the future.
 
May  4  2011 addautos.sas
May  4  2011 adddecodevars.sas
Jan 29  2012 adjfmt.sas
May  4  2011 after.sas
May  4  2011 age.sas
May  4  2011 agedec.sas
May  4  2011 aligndp.sas
Apr 13  2011 allfmtvals.sas
May  4  2011 alluniq.sas
Aug 23  2012 appmvar.sas
May  4  2011 attrc.sas
May  4  2011 attrn.sas
May  4  2011 attrv.sas
May  4  2011 bydrop.sas
May  4  2011 bytitle.sas
Jan 11 18:02 capmac.sas
May  4  2011 capvar.sas
May  4  2011 casestrmac.sas
May  4  2011 casestrvar.sas
Mar 15 17:33 char2num.sas
May 11  2011 checkv6.sas
May  4  2011 chkuniq.sas
May  4  2011 chompw.sas
Nov  2  2011 clashlibs.sas
Nov  2  2011 clashvars.sas
May  4  2011 clength.sas
Jun 14 19:21 combine.sas
Feb 11  2012 comma2andmac.sas
Feb 11  2012 comma2andvar.sas
Mar 26 19:31 commaparms.sas
Apr 16 18:21 commaparmsu.sas
May  4  2011 commas.sas
May  8  2011 complibs.sas
May  4  2011 compress.sas
Nov  8  2011 compvars.sas
May  4  2011 crdte.sas
Sep 28  2008 datanulldemo.sas
May  4  2011 delhex.sas
Apr  5  2011 delifexist.sas
Jul 20  2012 delmac.sas
May  4  2011 delzero.sas
May  4  2011 dequote.sas
Apr 25 19:29 dir.sas
Apr 25 19:29 dir2sas.sas
Apr 25 19:28 dirfp2sas.sas
Apr 25 19:29 dirfpq.sas
May  2 23:17 dlm2sas.sas
Jun  9  2011 doallitem.sas
Nov 15  2011 dosfdasize.sas
Nov 15  2011 dosfilesize.sas
Apr 16 18:21 dropend.sas
Jun 11 17:36 dropmodifiers.sas
Jun 14 19:21 dropmodifmac.sas
May  4  2011 dropvars.sas
May  4  2011 dsall.sas
Apr  2 20:42 dsattr.sas
May  8  2011 dsattrib.sas
May  4  2011 dslabel.sas
May  4  2011 dslist.sas
May  6 21:45 dsplit.sas
May  4  2011 dtscale.sas
May  4  2011 duplvars.sas
Nov  1  2012 editlist.sas
May  4  2011 endwith.sas
Jul 25  2011 env2ds.sas
Jul 25  2011 env2dsw7.sas
May  4  2011 eqsuff.sas
May  4  2011 equals.sas
May  4  2011 fixnames.sas
May  8  2011 fixvars.sas
May  4  2011 flatten.sas
May  4  2011 fmtord.sas
Apr 13  2011 fmtpath.sas
May  4  2011 fmts2fda.sas
Sep 15  2012 getfmts.sas
Sep 19  2011 gettitles.sas
Sep 15  2012 getvalue.sas
Sep 15  2012 getvalueq.sas
May  4  2011 globexist.sas
May  4  2011 globlist.sas
May  4  2011 hasvars.sas
May  4  2011 hasvarsc.sas
May  4  2011 hasvarsn.sas
May  2 23:16 hexchars.sas
May  4  2011 hexcnt.sas
Nov 27  2012 int2num.sas
Dec 14 20:17 isodatepart.sas
Dec 14 20:09 isodttm.sas
Dec 14 20:00 isoformats.sas
Dec 14 20:20 isotimepart.sas
Jul 26  2011 killsas.sas
Jul 26  2011 killsess.sas
Mar  6  2012 ksplitvar.sas
May  4  2011 lafootnote.sas
May  4  2011 latitle.sas
May  4  2011 lcralign.sas
May  4  2011 left.sas
May  4  2011 liblist.sas
May  4  2011 ljustify.sas
May  4  2011 lookahead.sas
May  4  2011 lrafootnote.sas
May  4  2011 lratitle.sas
Jun 26  2011 ls.sas
Apr 23 07:41 ls2sas.sas
Apr 23 07:41 lsfp2sas.sas
Jun 26  2011 lsfpq.sas
Jun  4 17:59 lslist2sas.sas
Apr  2 19:41 lstattrib.sas
Jan 19  2012 lstlbls.sas
May  4  2011 ltgtm1.sas
Apr 25 19:28 match.sas
May  4  2011 maxtitle.sas
Aug 12  2011 md5sum.sas
Apr  9 19:28 misscnt.sas
Jan 19  2012 missvars.sas
Jun  4 07:27 mkformat.sas
Oct 26  2011 mkordinfmt.sas
May  4  2011 modte.sas
May  4  2011 mtype.sas
May  4  2011 mvarlist.sas
May  4  2011 mvarvalues.sas
May  4  2011 nlobs.sas
May  4  2011 nobs.sas
May  4  2011 nodup.sas
May  4  2011 nodupkey.sas
May  4  2011 noquotes.sas
Mar 19 20:17 now.sas
May  4  2011 numchars.sas
May  4  2011 nvars.sas
May  4  2011 nvarsc.sas
May  4  2011 nvarsn.sas
Apr  2 19:13 optlength.sas
Apr  4 19:25 optvarlen.sas
May  4  2011 partialdates.sas
Jun 12  2011 prefix.sas
May  4  2011 printall.sas
Feb  1  2011 prxnames.sas
May  4  2011 putvars.sas
Sep 23  2011 qcompress.sas
Nov 16  2011 qdequote.sas
May  4  2011 qdosfileinfo.sas
May  4  2011 qgetenv.sas
Sep 23  2011 qreadpipe.sas
May  4  2011 quotecnt.sas
May  4  2011 quotelst.sas
May  4  2011 quotescan.sas
May  4  2011 rafootnote.sas
May  4  2011 rannomac.sas
May  4  2011 ratitle.sas
Aug 12  2011 rcmd2ds.sas
Aug 12  2011 rcmd2log.sas
Aug 12  2011 rcmd2mvar.sas
May  4  2011 readfile.sas
May  4  2011 remove.sas
Dec  5  2012 removew.sas
Feb 12  2011 rename8.sas
May  4  2011 replhex.sas
Jun 12  2011 rinclude.sas
May  4  2011 round.sas
May  4  2011 rxmatch.sas
Apr 25 19:31 samevars.sas
Oct 15  2011 sas2tabdlm.sas
Aug 10  2012 sas2xpt.sas
Jun 14  2011 savopts.sas
Mar 25 01:39 scandlm.sas
Sep 19  2011 scanfile.sas
Aug 19  2011 scanlog.sas
Mar 26 19:26 sep2sp.sas
Aug 24  2012 sep2u.sas
May  4  2011 showhex.sas
May  4  2011 sortedby.sas
May  8  2011 splitmac.sas
Mar  6  2012 splitvar.sas
Apr 30 16:28 sqlsamevars.sas
May  4  2011 substrw.sas
Jun 12  2011 suffix.sas
May  4  2011 supasort.sas
Oct 10  2012 superql.sas
May  4  2011 sysfmtlist.sas
May  2 23:17 termstr.sas
May  4  2011 therest.sas
May  4  2011 titlelen.sas
May  4  2011 trim.sas
Apr 20 07:55 unfmt2mvar.sas
May  8  2011 v_macros.sas
Sep  9  2011 var2mvar.sas
May  4  2011 varfmt.sas
May  4  2011 varinfmt.sas
May  4  2011 varlabel.sas
May  4  2011 varlen.sas
May  4  2011 varlist.sas
May  4  2011 varlistc.sas
May  4  2011 varlistn.sas
May  4  2011 varnum.sas
Nov 27  2012 vars2num.sas
May  4  2011 vartype.sas
May  4  2011 vaxis.sas
May  4  2011 verify.sas
May  4  2011 verifyb.sas
May  4  2011 vwlist.sas
May  4  2011 windex.sas
Aug 24  2012 worddate.sas
Aug 24  2012 worddateu.sas
Jan  9 18:04 words.sas
Jun 26  2011 xl2sas.sas
Sep 15  2012 xlblocks.sas
Jun 26  2011 xlsheets.sas
Feb  2  2011 xpt2sas.sas
May  4  2011 yrcutoff.sas
May  4  2011 zerogrid.sas

Utility macro purposes

Index of members in this directory with standard headers
========================================================
(this list was generated by the crindex script)

addautos.sas       - To concatenate a macro library onto the sasautos path

                     Usage: %addautos(mymacros)
 

adddecodevars.sas  - To add decode variables where a user format is specified

                     Usage: %adddecodevars(dsin=ds1,dsout=ds2)
 

adjfmt.sas         - To create a format based on a current format that can be
                     adjusted by indenting the labels or by adding leading and
                    trailing underscores.

                     Usage: %adjfmt(agernge,adjrnge,indent=4)
                     %adjfmt(agernge,adjrnge,underscore=yes)

after.sas          - Function-style macro to give you what comes directly after a
                     target string.

                     Usage: %let width=%after(&str,%str(width=),%str( w=));
 

age.sas            - In-datastep function-style macro to calculate the age of a person
                     on a date.

                     Usage: data test;
                     age=%age(dob,date);
 

agedec.sas         - In-datastep function-style macro to calculate the age of a person
                     on a date as a decimal age.

                     Usage: data test;
                     agedec=%agedec(dob,date);
 

aligndp.sas        - In-datastep macro to create a string from a numeric value with
                     decimal points aligned.

                     Usage: %aligndp(numvar,charvar,4);
 

allfmtvals.sas     - Create a dataset with every start value of a format in it

                     Usage: %allfmtvals(fmt=$country,var=country,dsout=temp1,length=2)
                     %allfmtvals(fmt=site,var=site,dsout=temp2)
 

alluniq.sas        - To create a dataset with all unique occurences of a variable
                     throughout a library.

                     Usage: %alluniq(in,subject,allsubj)
 

appmvar.sas        - Function-style macro to append a string onto an existing macro
                     variable.

                     Usage: %let err_msg=%appmvar(err_msg,This is another error message);
                     %let err_msg=%appmvar(err_msg,
                     Add this comma-delimited list (%nrbquote(&list)));
 

attrc.sas          - Function-style macro to return a character attribute of a dataset

                     Usage: %let dslabel=%attrc(dsname,label);
                     %let sortseq=%attrc(dsname,sortedby);
 

attrn.sas          - Function-style macro to return a numeric attribute of a dataset

                     Usage: %let nobs=%attrn(dsname,nlobs);
 

attrv.sas          - Function-style macro to return a variable attribute

                     Usage: %let vartype=%attrv(dsname,varname,vartype);
 

bydrop.sas         - To drop by-group residuals

                     Usage: %bydrop(dsin,by1 by2)
 

bytitle.sas        - To drop the last title if it is a "by" title and write it to the
                     global macro variable _bytitle_ instead.

                     Usage: %bytitle
 

capmac.sas         - Function-style macro to capitalise the first letter of each
                     word in a macro string.

                     Usage: %let tidy=%capmac(%bquote(A, B AND C'S RESULTS));
 

capvar.sas         - In-datastep macro to tidy case of text in a variable

                     Usage: data lparmcd;
                     set lparmcd;
                     %capvar(put(lparmcd,lparmcd.),newvar,
                     ignore="SGOT" "SGPT" "PTT" "LDH" "GGT" "BUN");
                     run;

casestrmac.sas     - Function-style macro to force mixed case forms of a string into
                     the string itself for a macro expression.

                     Usage: %let newtext=%casestrvar(&oldtext,Roland);

casestrvar.sas     - In-datastep macro to force mixed case forms of a string into the
                     string itself.

                     Usage: data test2;
                     set test;
                     %casestrvar(text,'Roland');
                     run;

char2num.sas       - To "effectively" convert a list of character variables to numeric

                     Usage: %char2num(test,test2,char1 char2 char3 char4)
 

checkv6.sas        - Check a dataset for Version 6 compatibility

                     Usage: %checkv6(sasuser.myds);
 

chkuniq.sas        - To check for uniqueness in key variables.

                     Usage: %chkuniq(dsname)
 

chompw.sas         - Function-style macro to cut out a word from a macro string and
                     optionally cut out words before and/or after it.

                     Usage: %let str2=%chompw(&str1,&target,2,0,casesens=yes);
 

clashlibs.sas      - To identify where there is a clash of variable characteristics for
                     the specified dataset(s) in the multiple assigned libraries and to
                     output diagnostics. Case is important for variable names. To make
                     sure all variable names are created in upper case then use the
                     system option VALIDVARNAME=UPCASE before you create the datasets.

                     Usage: %clashlibs(myds)
 

clashvars.sas      - To identify where there is a clash of variable characteristics for
                     datasets in a library and to output diagnostics.

                     Usage: %clashvars(mylib)
 

clength.sas        - To create a length statement to unify character lengths in a list
                     of data sets to the maximum variable length.

                     Usage: %clength(ds1 ds2 ds3);
                     data all;
                     &_clength_;
                     set ds1 ds2 ds3;
                     run;
 

combine.sas        - To combine datasets based on merge variables

                     Usage: %let mrgvars=study ptno;
                     %let SrcData=
                     sasuser.test(keep=&mrgvars visit vara varc), 
                     sasuser.patd(keep=&mrgvars page scrndt trtstdt where=(page=1)),
                     sasuser.patd(keep=&mrgvars page brthdt where=(page=2)),
                     sasuser.vital(keep=&mrgvars visit bmi where=(visit=1));
                     %combine(SourceData=%nrbquote(&SrcData),MergeVars=&mrgvars);
 

commaparms.sas     - Function-style macro to add back commas between macro parameters
                     where these have been deliberately omitted in a string.

                     Usage: %let params=%commaparms(&str);
 

commaparmsu.sas    - Function-style macro to add back commas between macro parameters
                     where these have been deliberately omitted in a string and to 
                     convert parameter names to uppercase.

                     Usage: %let params=%commaparmsu(&str);
 

commas.sas         - Function-style macro to separate the elements of a list with
                     commas.

                     Usage: order by %commas(&var1 &var2 &var3);
 

complibs.sas       - To "proc compare" identically-named datasets in two libraries

                     Usage: %complibs(base,comp)
 

compress.sas       - Function-style macro to compress a macro string

                     Usage: %let str2=%compress(&str,1234567890.);
 

compvars.sas       - To compare the differences in variables present in two datasets
                     and report the results to global macro variables.

                     Usage: %let ds1=dataset1;
                     %let ds2=dataset2;
                     %compvars(&ds1,&ds2)
                     options nosource;
                     %put NOTE: Variables found in &ds1 but not &ds2:;
                     %put &_left_;
                     %put NOTE: Variables found in &ds2 but not &ds1:;
                     %put &_right_;
                     %put NOTE: Variables found in both &ds1 and &ds2:;
                     %put &_both_;
                     options source;

crdte.sas          - Function-style macro to return the creation datetime stamp of a
                     dataset.

                     Usage: %let crdte=%crdte(dsname);
 

datanulldemo.sas   - Clinical reporting sample code to do a stacked-column report using
                     data _null_ that does not leave line gaps like proc report does.

                     Usage: Ordinary SAS code.
 

delhex.sas         - To delete occurrences of a specified hex character in a flat file.

                     Usage: %delhex(infile,outfile,'FE'x)
 

delifexist.sas     - To delete a dataset if it exists

                     Usage: %delifexist(sasuser.myds)
 

delzero.sas        - To delete all datasets in a library with zero observations. This
                     macro was written for illustration purposes and is of limited use.

                     Usage: %delzero(work)

dequote.sas        - Function-style macro to remove front and end matching quotes
                     from a macro string and return the result.

                     Usage: %let str=%dequote(%qreadpipe(echo '%username%'));

dir2sas.sas        - To write a list of windows file names to a sas dataset

                     Usage: %dir2sas(\\Client\C$\MYLIB\*.txt);

dirfp2sas.sas      - To write a list of windows full path file names to a sas dataset

                     Usage: %dirfp2sas(\\Client\C$\MYLIB\*.txt);

dir.sas            - Function-style macro to return a list of members of a directory
                     on a WINDOWS platform according to the file pattern you supply.
                     If you supply just the directory name then all members are
                     listed. This runs the MSDOS command in the form "dir /B mydir"

                     Usage: %let dirlist=%dir(C:\utilmacros);
                     %let dirlist=%dir(C:\utilmacros\*.sas);

dirfpq.sas         - Function-style macro to return a list of full-path quoted members
                     of a directory on a Windows platform according to the file pattern
                     you supply.

                     Usage: %let dirlist=%dirfpq(C:\utilmacros);     %*- NO GOOD -;
                     %let dirlist=%dirfpq(C:\utilmacros\*);      %*- GOOD -;
                     %let dirlist=%dirfpq(C:\utilmacros\*.sas);  %*- GOOD -;

dlm2sas.sas        - To read in a delimited flat file and convert it to a sas dataset

                     Usage: %dlm2sas(C:\Mylib\myfile.csv,mydset)

doallitem.sas      - To execute code for each item in a space-delimited list

                     Usage: %doallitem(dsa dsb dsc,'proc sort data=&item;by var;run;');
 

dosfdasize.sas     - Function-style macro to check a dataset size and obs count against
                     FDA guideline limits.

                     Usage: %if %dosfdasize(dset) EQ NOTOK %then %do;

dosfilesize.sas    - Function-style macro to return a DOS file size or a sas dataset
                     size in bytes.

                     Usage: %let filesize=%dosfilesize(C:\spectre\unistats.html);
 

dropend.sas        - Function-style macro to drop the end of a string along with the
                     specified delimiter.

                     Usage: %let str=aaa\bbb\cccc\ddddd\eeee\pgm;
                     %put >>>>> %dropend(&str,\\)\data;
                     >>>>> aaa\bbb\cccc\ddddd\eeee\data

                     %let str=aaa/bbb/cccc/ddddd/eeee/pgm;
                     %put >>>>> %dropend(&str,/)/data;
                     >>>>> aaa/bbb/cccc/ddddd/eeee/data

dropmodifiers.sas  - In-datastep macro to remove the dataset modifiers from a variable
                     that contains single or multiple dataset names with possible
                     modifiers.

                     Usage: data test;
                              set dset(keep=sourcedata domain);
                              %dropmodifiers(sourcedata);
                              *- now process the pure dataset names in sourcedata -;
                              put sourcedata=;
                            run;

dropmodifmac.sas   - Function-style macro to return a string with dataset modifiers
                     removed from a macro variable string containing single or multiple
                     dataset names with possible modifiers.

                     Usage: %let str=ds1(where=(a=:")" and b=:')')) lib.ds2(drop = v1 v2);
                     %put >>> %dropmodifmac(%superq(str));
                     >>> ds1 lib.ds2

dropvars.sas       - To drop a list of unwanted variables in a list of datasets.

                     Usage: %dropvars(work._all,x1 x2)
 

dsall.sas          - To expand out the _all_ in a dataset list into all datasets in the
                     library.

                     Usage: %dsall(sasuser.test work._all_);
                     %let dsall=&_dsall_;

dsattr.sas         - Extract attributes for a dataset from dictionary.columns

                     Usage: %dsattr(sashelp.class,classattr);
 

dsattrib.sas       - To force a set of attributes, held in a template dataset,
                     on another dataset.

                     Usage: %dsattrib(template,inds,outds)
 

dslabel.sas        - Function-style macro to return a dataset label

                     Usage: %let dslabel=%dslabel(dsname);
 

dslist.sas         - To list all the datasets in a libref.

                     Usage: %dslist(work);
                     %let dslist=&_dslist_;

dsplit.sas         - To split up a space delimited list of datasets (with possible
                     complex modifiers involving nested and quoted brackets) into
                     individual datasets with their corresponding modifiers and write
                     them to global macro variables.

                     Usage: %let str=dset1  dset2( keep= aa bb cc ) dset3( drop = dd ee )
                     dset4;
                     %dsplit(%nrbquote(&str));
                     %put _dsplitnum_=&_dsplitnum_;
                     %put _dsplit1_=&_dsplit1_;
                     %put _dsplit2_=&_dsplit2_;
                     %put _dsplit3_=&_dsplit3_;
                     %put _dsplit4_=&_dsplit4_;

dtscale.sas        - To generate a date scale for sas/graph

                     Usage: %dtscale(&min,&max);
 

duplvars.sas       - Function-style macro to create a list of duplicate variables in a
                     second dataset so that they can be dropped before a merge.

                     Usage: data newds;
                     merge ds1 ds2(drop=%duplvars(ds1,ds2,&bylist));
                     by &bylist;
                     run;
 

editlist.sas       - Function-style macro to allow you to edit a list of space 
                     delimited items.

                     Usage: %put >>> %editlist(aa bb cc dd,'&item=mr_&item');
                     %put >>> %editlist(xx_aa xx_bb xx_cc,
                     '&item=%substr(&item,4)');
                     %put >>> %editlist(xx_aa xx_bb xx_cc,
                     '%substr(&item,4)=&item%nrbquote(;)');

                     (will write to log:)
                     >>> aa=mr_aa bb=mr_bb cc=mr_cc dd=mr_dd
                     >>> xx_aa=aa xx_bb=bb xx_cc=cc
                     >>> aa=xx_aa; bb=xx_bb; cc=xx_cc;
 

endwith.sas        - Function-style macro to ensure any non-null value assigned to a
                     macro variable ends with the specified character.

                     Usage: filename outfile "%endwith(&outdir,/)output.txt";
 

env2ds.sas         - To write system and user environment variables to a dataset.

                     Usage: %env2ds;
                     %env2ds(OutputDatasetName);

env2dsw7.sas       - To write system and user environment variables to a dataset for
                     the Windows 7 operating system.

                     Usage: %env2dsw7;
                     %env2dsw7(OutputDatasetName);

eqsuff.sas         - Function-style macro to suffix a list of words (usually variables)
                     with an equals sign.

                     Usage: put %eqsuff(&varlist);
 

equals.sas         - In-datastep function-style macro to compare two numeric values to
                     find if they are equal or very nearly equal.

                     Usage: if %equals(val1,7.3) then ...
 

fixnames.sas       - In-datastep macro to fix UTF-8 characters in a person's name by
                     converting the UTF-8 character pairs back to ascii.

                     Usage: data newpatinfo;
                     set patinfo;
                     %fixnames(invname)
                     run;

fixvars.sas        - To "fix" variables in a library so they are consistent

                     Usage: fixvars(mylib,w);
 

flatten.sas        - To "flatten" data so there is only one observation per "by group"

                     Usage: %flatten(dsin=test,bygroup=by1 by2,vars=str num)
 

fmtord.sas         - To create a numeric informat that maps a format label to its
                     order position.

                    Usage: %fmtord(agernge);
 

fmtpath.sas        - Function-style macro to get the full fmtsearch path

                     Usage: %let path=%fmtpath;
 

fmts2fda.sas       - To create sas code to generate formats as found in your data

                     Usage: %fmts2fda(mylib1 mylib2)
 

getfmts.sas        - To get details of a list of user formats defined in a dataset

                     Usage: %getfmts(dsin=fmtlist,fmtvar=format,dsout=allfmts);
 

gettitles.sas      - To read the title lines of an LST file and write them to a global
                     macro variable _titles_ .

                     Usage: %gettitles(C:\temp\myfile.lst)
 

getvalue.sas       - Function-style macro to return a variable's value

                     Usage: %let value=%getvalue(dsname,varname,1);
 

getvalueq.sas      - Function-style macro to return a variable's value

                    Usage: %let value=%getvalueq(dsname,varname,1);
 

globexist.sas      - Function-style macro to return true if all the global macro
                     variables listed exist.

                     Usage: %if %globexist(globvar) %then %do ....
 

globlist.sas       - Function-style macro to return a list of current global macro
                     variable names.

                     Usage: %let glist=%globlist;
 

hasvars.sas        - Function-style macro to return true if a dataset has all the
                     variables defined to a list.

                     Usage: %if not %hasvars(dsname,aa bb cc) %then %do ....
 

hasvarsc.sas       - Function-style to return true if a dataset has all the character
                     variables defined to a list.

                     Usage: %if not %hasvarsc(dsname,aa bb cc) %then %do ....
 

hasvarsn.sas       - Function-style macro to return true if a dataset has all the
                     numeric variables defined to a list.

                     Usage: %if not %hasvarsn(dsname,aa bb cc) %then %do ....
 

hexchars.sas       - To show up ascii non-printables characters in a flat file by
                     displaying their ascii codes as hexadecimal numbers in "< >"
                     symbols.

                     Usage: %hexchars(infile.ext)
                     %hexchars(infile.ext,"outfile.ext")
                     %hexchars(infile.ext,outfile.ext)
                     %hexchars("infile.ext")
                     %hexchars("infile.ext",print)
                     %hexchars("infile.ext","log")

hexcnt.sas         - To count the strange hex character in character variables

                     Usage: %hexcnt(dsname,droplist,globcnt=_hexcnt_,globvars=_hexvars_);

int2num.sas        - To convert variables to numeric where you know they should be
                     integer variables.

                     Usage: 
                     data test2;
                       set test1;
                       %int2num(vara varb varc vard)
                     run;
 

isodatepart.sas    - In-datastep function-style macro for extracting the date part of a
                     standard ISO 8601 datetime text value.

                     Usage:
                     data test;
                       set test;
                       date=%isodatepart(isodttmvar);

isodttm.sas        - In-datastep function-style macro for generating a standard ISO
                     8601 datetime value from a numeric date and time value.

                     Usage:
                     data test;
                       length dtc $ 20;
                       set test;
                       dtc=%isodttm(datevar,timevar);
 

isoformats.sas     - Macro to define the ISO 8601 formats used by the %isodttm macro
                     for generating an ISO 8601 datetime string.

                     Usage: %isoformats;
 

isotimepart.sas    - In-datastep function-style macro for extracting the time part of a
                     standard ISO 8601 datetime text value.

                     Usage:
                     data test;
                       set test;
                       time=%isotimepart(isodttmvar);
 

killsas.sas        - To kill any user's SAS session except the one running this macro

                     Usage: %killsas
 

killsess.sas       - To kill a Windows SAS session

                     Usage: %killsess
                     %killsess(2)

lafootnote.sas     - To create a left-aligned footnote

                     Usage: %lafootnote(2,"  second footnote indented two spaces")
 

latitle.sas        - To create a left-aligned title

                     Usage: %latitle(2,"  second title indented two spaces")
 

lcralign.sas       - Write to a macro variable with the supplied text left, center
                     and right-aligned.

                     Usage: %let macvar=;
                     %lcralign(macvar,50,"left bit","center bit","right bit")
                     %put macvar=*&macvar*;

left.sas           - Function-style macro to left-align the contents of a macro
                     variable.

                     Usage: %let macvar=%left(&macvar);
 

liblist.sas        - To list all the libraries.

                     Usage: %liblist;
                     %let liblist=&_liblist_;

ljustify.sas       - To left-justify all character fields in a dataset

                     Usage: %ljustify(dset)
 

lookahead.sas      - To do the opposite of lag and allow the user to look ahead at the
                     variables in the following observations in the same by group.

                     Usage: 
 

lrafootnote.sas    - To left and right-align a two part footnote for a pure text output

                     Usage: %lrafootnote(5,"Left aligned","Right-aligned")
 

lratitle.sas       - To left and right-align a two part title for a pure text output
§
                     Usage: %lratitle(5,"Left aligned","Right-aligned")
 

ls2sas.sas         - To write a list of Unix/Linux file names to a sas dataset

                     Usage: %ls2sas(./MYLIB/*.txt);
 

lslist2sas.sas     - To read the results of the Unix/Linux "ls" command into a dataset

                     Usage: lslist2sas(my-text-file); 
 

lsfp2sas.sas       - To write a list of Unix/Linux full path file names to a dataset

                     Usage: %lsfp2sas(./MYLIB/*.txt);
 

ls.sas             - Function-style macro to return a list of members of a directory
                     on a Unix platform according to the file pattern you supply.
                     If you supply just the directory name then all members are
                     listed. This runs the Unix command in the form "ls -1 mydir" .

                     Usage: %let dirlist=%ls(/usr/utilmacros);
                     %let dirlist=%ls(/usr/utilmacros/*.sas);

lsfpq.sas          - Function-style macro to return a list of full-path quoted members
                     of a directory on a Unix platform according to the file pattern
                     you supply.

                     Usage: %let dirlist=%lsfpq(/usr/mylib);     %*- NO GOOD -;
                     %let dirlist=%lsfpq(/usr/mylib/*);      %*- GOOD -;
                     %let dirlist=%lsfpq(/usr/mylib/*.sas);  %*- GOOD -;
 

lstattrib.sas      - Lists the variable attributes of the specified dataset in the
                     form of a LENGTH statement and ATTRIB statement that can be used
                     in sas code.

                     Usage: %lstattrib(sasuser.demog)

lstlbls.sas        - To list variables and their labels to the log

                     Usage: %lstlbls(dsname(keep=aa bb cc dd),16);

ltgtm1.sas         - In-datastep macro to turn a text numeric value into a numeric
                     value and handle "<" and ">" signs preceding and adjust the value
                     according to a rule (method 1).

                     Usage: %ltgtm1(textvar,numvar);
 

match.sas          - Function-style macro to return elements of a list that match those
                     in a reference list.

                     Usage: %let match=%match(aa bb,aa cc);
 

maxtitle.sas       - To find the highest number title and footnote and output to global
                     macro variables.

                     Usage: %maxtitles
 

md5sum.sas         - To write the md5 checksum to the log for a two-level dataset
                     stored on Unix or Linux.

                    Usage: %md5sum(outads.basco)
 

misscnt.sas        - To create a list of variables and their missing value count

                     Usage: %misscnt(dsname,droplist,globvar=_miss_);

missvars.sas       - To create a list of all-missing variables

                     Usage: %missvars(dsname);
                     run;
                     data dsname;
                     set dsname(drop=&_miss_);
                     run;

mkformat.sas       - To create a format out of a "coded" and "decoded" variable in a
                     specified dataset.

                     Usage: %mkformat(dsname(where=(x>1)),varcd,vardcd,fmtname,fmtcat);
 

mkordinfmt.sas     - To create a numeric informat to map character strings to an
                     ordering rank value.

                     Usage: %mkordinfmt(fmtname=lvl,dsin=test,var=str,ordvar=order)
                     %mkordinfmt(fmtname=lvl,dsin=test,var=str)

modte.sas          - Function-style macro to return the last modification datetime
                     stamp of a dataset.

                     Usage: %let modte=%modte(dsname);
 

mtype.sas          - Function-style macro to return the member type of a dataset
                     (i.e. whether DATA or VIEW).

                     Usage: %let mtype=%mtype(dsname);
 

mvarlist.sas       - Function-style macro to return a list of macro variable names
                     satisfying the supplied scope.

                     Usage: %macro dummy(a=123,b=345,c=);
                     %let setparmlist=%mvarlist(dummy,s);
                     %mend dummy;

mvarvalues.sas     - Lists and resolves macro variables one per line for a supplied
                     macro variable list.

                     Usage: %mvarvalues(&mvarlist,*);
                     %mvarvalues('%mvarlist(dummy9,a)',**);

nlobs.sas          - Function-style macro to return the number of logical observations
                     (i.e. not marked for deletion) in a dataset or view. This will
                     either be a positive integer or forced to zero.

                     Usage: %put >>>>>> %nlobs(sashelp.class) >>>>;
                     %put >>>>>> %nlobs(sashelp.class(where=(sex="M"))) >>>>;
                     %put >>>>>> %nlobs(sashelp.vtable) >>>>;

nobs.sas           - Function-style macro to return the number of observations in a
                     dataset or view. This will either be a positive integer or forced
                     to zero.

                     Usage: %put >>>>>> %nobs(sashelp.class) >>>>;
                     %put >>>>>> %nobs(sashelp.class(where=(sex="M"))) >>>>;
                     %put >>>>>> %nobs(sashelp.vtable) >>>>;

nodup.sas          - Function-style macro to drop duplicates in a space-delimited list

                     Usage: %let str=%nodup(aaa bbb aaa);
 

nodupkey.sas       - To sort "nodupkey" but list observations being dropped so that
                     they can be investigated and accounted for.

                     Usage: %nodupkey(ds,var1 var2 var3)
 

noquotes.sas       - Function-style macro to remove all quoted strings from a macro
                     expression.

                     Usage: %let noquotes=%noquotes(&str);
 

now.sas            - Function-style macro to return the current timestamp

                     Usage: %put Stage1: %now;
 

numchars.sas       - To create a list of character variables that contain numeric-like
                     text.

                     Usage: %numchars(dsname,globvar=_numchars_);
                     %put ######## &_numchars_;

nvars.sas          - Function-style macro to return the number of variables in a
                     dataset.

                     Usage: %let nvars=%nvars(dsname);
 

nvarsc.sas         - Function-style macro to return the number of character variables
                     in a dataset.

                     Usage: %let nvarsc=%nvarsc(dsname);
 

nvarsn.sas         - Function-style macro to return the number of numeric variables in
                     a dataset.

                     Usage: %let nvarsn=%nvarsn(dsname);
 

optlength.sas      - To create a length statement for character variables that take up
                     less length than that allotted to the variable.

                     Usage: optlength(dset)
                     data dset;
                     &_optlength_;
                     set dset;
                     run;
 

optvarlen.sas      - To create an output dataset with the same variable order as the
                     input dataset but with character variables reduced to their
                     optimum length such that they are long enough to hold the longest
                     value but no longer.

                     Usage: %optvarlen(sashelp.class,classattr);
 

partialdates.sas   - In-datastep macro to impute partial dates to a high or low value

                     Usage: data test;
                     datestr="--feb08";
                     %partialdates(datetext=datestr,datevar=date,pattern="ddmmmyy",
                     lohi=high);
                     format date date9.;
                     put date= datestr=;
                     run;
                     29FEB2008

prefix.sas         - Function-style macro to return a list with a prefix added.

                     Usage: %let preflist=%prefix(C:\mylib\,fname1 "fname 2" fname3);
 

printall.sas       - To print every observation in a library where a variable satisfies
                     a specified condition.

                     Usage: %printall(work,%str(num>1))
 

prxnames.sas       - Function-style macro to convert a space-delimited list of sas
                     names (variable or dataset names) to a Pearl Regular Expression
                     for use in the prxmatch() function that takes into account the
                     ending colon notation.

                     Usage: %let dslist=var1 var2 vx:;
                    ....where prxmatch(%prxnames(&dslist),memname);

putvars.sas        - To list variables in a dataset suffixed with an equals sign
                     suitable for a "put" statement written to the log.

                     Usage: put %putvars(ds);
 

qcompress.sas      - Function-style macro to compress a macro variable string and
                     return the result MACRO QUOTED.

                     Usage: %let tidy=%qcompress(&string);
 

qdequote.sas       - Function-style macro to remove front and end matching quotes
                     from a macro string and return the result MACRO QUOTED.

                     Usage: %let str=%qdequote(%qreadpipe(echo '%username%'));
                     CLASS %unquote(%qdequote('&trtvar')) ;

qdosfileinfo.sas   - Function-style macro to return information about a DOS file
                     and return the result MACRO QUOTED.

                     Usage: %let filesize=%qdosfileinfo(C:\spectre\unistats.html,z);

qgetenv.sas        - Function-style macro to get the contents of a system or user
                     environment variable and return the result MACRO QUOTED.

                     Usage: %let newvar=%qgetenv(uservar);
 

qreadpipe.sas      - Function-style macro to read the output of a system command and
                     return the result trimmed and MACRO QUOTED.

                     Usage: %let mvar=%qreadpipe(echo $USER);
 

quotecnt.sas       - Function-style macro to count quoted strings in a macro expression

                     Usage: %let count=%quotecnt(&str);
 

quotelst.sas       - Function-style macro to quote the elements of a list

                     Usage: %if %index(%quotelst(varnames),"varname") %then...
 

quotescan.sas      - Function-style macro to scan for a quoted string in a macro
                     expression.

                     Usage: %let scan=%quotescan(&str,2);
 

rafootnote.sas     - To right-align a footnote for a pure text output

                     Usage: %rafootnote(5,"This footnote 5 will be right-aligned")
 

rannomac.sas       - Compile Roland's annotate macros

                     Usage: filename webout "C:\spectre\";

                     goptions reset=all xpixels=1000 ypixels=6000 hpos=50 vpos=300
                     dev=gif gsfmode=replace transparency border
                     ftext='Arial' htext=1 cell ctext=CX483D8C; * DarkSlateBlue ;

                     ods listing close;
                     ods html path=webout body="annotest.html";

                     %rannomac

                     data test;
                     %dclannovars
                     %rarrow(y=298,x1=20,x2=48)
                     %text(y=298,x=19,position='<',text="right-aligned text")
                     %rarrow(y=297,x1=20,x2=48,fillcolor='green',
                     linecolor='black',fillpattern='mempty')
                     %text(y=297,x=19,position='<',text="next line of text")
                     %text(y=296,x=19,position='<',
                     text="This has a hotspot but misaligned on the left",
                     color='maroon',
                     html="alt='This hotspot is misaligned on the left of the text'")
                     %box(y=295,x=25)
                     %box(y=295,x=35)
                     %box(y=295,x=45,html="alt='Third Box Hotspot'")
                     %text(y=295,x=19,position='<',
                     text="The third box ONLY should have a hotspot")
                     %bigbox(x1=20,y1=294.5,x2=50,y2=298.5,linecolor="brown")
                     run;

                     *- Set description to a space to stop whole output area -;
                     *- from having a hotspot and give the gif the same name -;
                     *- as the html body file. -;
                     proc ganno annotate=test description=" " name="annotest";
                     run;

                     *- If you rerun this code then you need to delete the -;
                     *- "annotest" grseg member in work.gseg so it can be  -;
                     *- reused as a name in the "proc ganno" step.  -;
                     proc greplay igout=gseg nofs;
                     delete annotest;
                     run;
                     quit;

                     ods html close;
                     ods listing;
 

ratitle.sas        - To right-align a title for a pure text output

                     Usage: %ratitle(5,"This title 5 will be right-aligned")
 

rcmd2ds.sas        - To run a system command on the remote host and write the output to
                     the dataset RWORK._rcmd.

                     Usage: %rcmd2ds(ls /root/usr/mylib)
 

rcmd2log.sas       - To run a system command on the remote host and write the output to
                     the log.

                     Usage: %rcmd2log(ps -fu userid); *- see details of a user-id -;
                     %rcmd2log(ps -fp 12345);  *- see details of a process-id -;

rcmd2mvar.sas      - To run a system command on the remote host and write the output to
                     a macro variable on the local host.

                     Usage: %rcmd2mvar(ps -fu userid,mymvar); *- see details of a user-id -;
                     %rcmd2mvar(ps -fp 12345,mymvar); *- see details of a process-id -;

readfile.sas       - Function-style macro to read in a flat file and assign the
                     contents to a macro variable.

                     Usage: %let mvar=%readfile(filename);
 

remove.sas         - Function-style macro to remove all occurrences of the target
                     string(s) from another string.

                     Usage: %let string2=%remove(&string1,XXX,yyy,YYY);
 

removew.sas        - Function-style macro to remove all occurrences of the target
                     word(s) from a source list of words.

                     Usage: %let colors2=%remove(&rainbow,green yellow);
 

rename8.sas        - Function-style macro to return a variable rename list for variable
                     names longer than 8 characters to shorten them to 8 characters.

                     Usage: data myds2;
                     set myds;
                     rename %rename8(myds);
                     run;

replhex.sas        - To replace occurrences of a specified hex character in a flat file
                     with another specified character.

                     Usage: %replhex(infile,outfile,'FE'x,' ')
 

rinclude.sas       - To submit local sas code members in the remote session

                     Usage: %rinclude(mylib(mymacro1.sas) "C:\mylib\mymacro2.sas"
                     %dirfpq(C:\macros\*.sas);
 

round.sas          - To round all the numeric variables in a list of datasets.

                     Usage: %round(work._all_)
 

rxmatch.sas        - Function-style macro to return those space-delimited elements of a
                     list that match a specified rxparse pattern.

                     Usage: %let match=%rxmatch(apopa pop aapop popaa,pop $s);
                     %put &match;
                     pop aapop

samevars.sas       - Function-style macro to return true (1) or false (0) if variables
                     in one dataset have the same variables and of the same type as
                     those in another dataset.

                     Usage:  %if not %samevars(dset1,dset2) %then %do....
 

sas2tabdlm.sas     - To write the contents of a sas dataset to a tab-delimited file

                     Usage: %sas2tabdlm(sashelp.cars,,yes)
                     %sas2tabdlm(sashelp.cars,C:\mylib\myfile.txt,yes)
                     %sas2tabdlm(sashelp.cars,"C:\mylib\myfile.txt",no)
                     %sas2tabdlm(sashelp.cars,"C:\mylib\myfile.txt")

sas2xpt.sas        - Create multiple transport files from sas datasets

                     Usage: %sas2xpt((INDSLIB),%nrstr("V:\SAS\Two Parts\X&Y\temp\"));

savopts.sas        - Function-style macro to return a list of active sas options so
                     that these options can be restored at a later point.

                     Usage: %let savopts=%savopts(missing mprint);
                     option &savopts;

scandlm.sas        - Function-style macro to return a scan of a string with its
                     delimiter shown in front.

                     Usage: %put %scandlm(&str,2,*#);

scanfile.sas       - Counts the number of lines of text in a file that contain the
                     string or the regular expression you specify within the line limit
                     you choose and optionally writes the line or blocks of lines to
                     the log.

                     Usage: %scanfile(C:\temp\myfile.lst,Treated,3,casesens=no)

                     *-- Complex example of scanning all the sas programs   --;
                     *-- in a library and printing the "proc format" steps. --;
                     %doallitem(%qreadpipe(dir /B C:\Mylib\*.sas),
                    '%scanfile(C:\Mylib\&item,proc format,
                     untilstr=run,notstr=cntlin,casesens=no)');

scanlog.sas        - To scan sas log file(s) or the log window for important messages
                     optionally using a "rules" file.

                     Usage: %scanlog("full-file-path-name")
                     %scanlog("full-file-path-name-1" "full-path-name-2")
                     %scanlog(fileref)
                     %scanlog(fileref(a.log) fileref(b.log))
                     %scanlog(fileref "full-path-name")
                     %scanlog(%lsfpq(/usr/mypath/*.log))
                     %scanlog(%dirfpq(C:\temp\*.log))
                     %scanlog(fileref(a.log) "full-path-name" %dirfpq(C:\temp\*.log))
                     %scanlog;         *- this is for interactive sas sessions -;
                     %scanlog(,log);   *- this is for interactive sas sessions -;
                     %scanlog(fileref,"output-file")
                     %scanlog(rulesfile=C:\temp\myrules.txt)
                     %scanlog(rulesfile="C:\temp\myrules.txt")
                     %scanlog(rulesfile="C:\temp\myrules.txt",prx=yes)
                     or in command line box for interactive sessions (note syntax):
                     gsubmit '%scanlog;'

sep2sp.sas         - Function-style macro to convert groups of commas and spaces in a
                     string to single spaces.

                     Usage: %let newstr=%sep2sp(%nrbquote(a  , b,    ,,, c));
 

sep2u.sas          - Function-style macro to convert groups of commas and spaces in a
                     string to single underscores.

                     Usage: %let newstr=%sep2u(%nrbquote(a  , b,    ,,, c));
 

showhex.sas        - To create a new dataset where hex characters in character
                     variables are highlighted.

                     Usage: %showhex(test1,test2,cvar1 cvar2 cvar3)
 

sortedby.sas       - Function-style macro to return the variables a dataset is sorted
                     by, or null if not sorted.

                     Usage: %let sortedby=%sortedby(dsname);
 

splitmac.sas       - Function-style macro to insert split characters in a macro string

                     Usage: %let str=The quick brown fox jumped over the lazy dog;
                     %let splitstr=%splitmac(&str,10);

splitvar.sas       - In-datastep macro to insert split characters in a string variable

                     Usage: data aaa;
                     set aaa;
                     %splitvar(oldvar,newvar,10,split=/,hindent=0);
                     run;
 

sqlsamevars.sas    - In-SQL macro to test if two datasets/tables have the same
                     variables (both names and type) and write the results as a 0 or 1
                     to a global macro variable.

                     Usage: proc sql noprint;
                     %sqlsamevars(dset1,dset2);
                     %if &_sqlsamevars_ EQ 0 %then %do ....
 

substrw.sas        - Function-style macro to substring words assigned to a macro
                     variable.

                     Usage: %let whatsleft=%substrw(&mvar,4);
                    %let twothree=%substrw(&str,2,2);

suffix.sas         - Function-style macro to return a list with a suffix added.

                     Usage: %let sufflist=%suffix(.sas,fname1 "fname 2" fname3);
 

supasort.sas       - To sort a list of datasets by variables if they exist in the
                     datasets.

                     Usage: %supasort(work._all_,date time)

superql.sas        - Function-style macro that uses as the argument the NAME of a 
                     macro variable and returns the length of the masked contents
                     of that variable as resolved by %superq().

                     Usage     : 
                     %macro test(parm1, parm2);
                       %if %superql(parm1) %then %put PARM1 is set;
                       %else %put PARM1 not set;
                     %mend test;
                     %test(aa,bb);
                     %test(,bb);
                     %test(R&D,bb);  %*- "&D" not resolvable --;

                     (log output with some text changed to fool log scanners)
                     955  %test(aa,bb);
                     PARM1 is set
                     956  %test(,bb);
                     PARM1 not set
                     957  %test(R&D,bb);  %*- "&D" is not resolvable --;
                     WA*NING: Appa*ent sym**lic refe*ence D not res*lved.
                     PARM1 is set

sysfmtlist.sas     - In-datastep macro to list all the system formats

                     Usage: if format in (" " %sysfmtlist) then _fmt="SYS";
                     else _fmt="USR";
 

termstr.sas        - To guess the line termination character(s) (CRLF or LF) of a text
                     input file and write it to the global macro variable _termstr_ .

                     Usage: %termstr(myfile);
                     %put _termstr_ = &_termstr_;
 

therest.sas        - Function-style macro to give you everything following any found
                     target string character.

                     Usage: %let rest=%therest(&str,\/);
 

titlelen.sas       - To create a copy of sashelp.vtitle but with the length added.

                     Usage: %titlelen
 

trim.sas           - Function-style macro to trim the contents of a macro variable

                     Usage: %let macvar=%trim(&macvar);
 

unfmt2mvar.sas     - To list distinct values of a variable to a macro variable but
                     without any variable format applied.

                     Usage: %unfmt2mvar(test, race sex, mrace msex);
 

v_macros.sas       - To compile the validation macros %mmm, %fmm, %dmm and set up
                     global macro variables "mut", "rut", "exp" and "act".

                     Usage: %v_macros

                     %let mut=removew;
                     %let rut=req001 req002;
                     %let days=mon tue wed thu fri sat;
                     %let act=%&mut(&days,tue fri);
                     %let exp=mon wed thu sat;
                     %mmm

var2mvar.sas       - To write data in a variable to a global macro variable

                     Usage: %var2mvar(sashelp.class(where=(name=:"A")),name);
                     %put **&_mvar_**;
                     **Alfred Alice**

varfmt.sas         - Function-style macro to return a variable format

                     Usage: %let varfmt=%varfmt(dsname,varname);
 

varinfmt.sas       - Function-style macro to return a variable informat

                     Usage: %let varinfmt=%varinfmt(dsname,varname);
 

varlabel.sas       - Function-style macro to return a variable label

                     Usage: %let varlabel=%varlabel(dsname,varname);
 

varlen.sas         - Function-style macro to return a variable length

                     Usage: %let varlen=%varlen(dsname,varname);
 

varlist.sas        - Function-style macro to return a list of variables in a dataset

                     Usage: %let varlist=%varlist(dsname);
 

varlistc.sas       - Function-style macro to return a list of character variables in a
                     dataset.

                     Usage: %let varlistc=%varlistc(dsname);
 

varlistn.sas       - Function-style macro to return a list of numeric variables in a
                     dataset.

                     Usage: %let varlistn=%varlistn(dsname);
 

varnum.sas         - Function-style macro to return the variable position in a dataset
                     or 0 if not in dataset.

                     Usage: %let varnum=%varnum(dsname,varname);

vars2num.sas       - To convert variables to numeric where you know they should be
                     numeric variables.

                     Usage: 
                     data test2;
                       set test1;
                       %vars2num(vara varb varc vard)
                     run;

vartype.sas        - Function-style macro to return a variable type as either C or N

                     Usage: %let vartype=%vartype(dsname,varname);
 

vaxis.sas          - To generate the values to construct a vaxis scale

                     Usage: %vaxis(&min,&max,spare=1)
 

verify.sas         - Function-style macro to return the position of the first character
                     in a string that does not match any character in a reference
                     string.

                     Usage: %let pos=%verify(&text,%str( )); %*- first non-blank character -;
 

verifyb.sas        - Function-style macro to return the position of the first character
                     in a string that does not match any character in a reference
                     string BUT STARTING FROM THE BACK.

                     Usage: %let pos=%verifyb(&text,%str( )); %*- last non-blank character -;
 

vwlist.sas         - To list all the views in a libref.

                     Usage: %vwlist(work);
                     %let vwlist=&_vwlist_;

windex.sas         - Function-style macro to return the word count position in a string

                     Usage: %let windex=%windex(string,target);
 

worddate.sas       - Function-style macro to convert a date in the form "date"D to a 
                     worddate format string.

                     Usage: %let worddate=%worddate("&sysdate9"D);
 

worddateu.sas      - Function-style macro to convert a date in the form "date"D to a 
                     worddate format string with groups of commas and spaces changed to
                     single underscores.

                     Usage: %let worddateu=%worddateu("&sysdate9"D);

words.sas          - Function-style macro to return the number of words in a string

                     Usage: %let words=%words(string);

xl2sas.sas         - Read an Excel spreadsheet into a sas dataset using DDE

                     Usage: %xl2sas(xlfile=C:\myfiles\My Spread Sheet.xls,sheetname=Sheet1,
                     dsout=sasuser.myspread,compress=no,vpref=_col,vlen=50,
                     startrow=5,startcol=1,endrow=95,endcol=10)

xlblocks.sas       - Read an Excel spreadsheet sheet containing blocks of
                     information using DDE with each block output as a numbered
                     dataset.

                     Usage: %xlblocks(xlfile=C:\myfiles\My Sheet.xls,sheetname=Sheet One,
                     dspref=sasuser.myspread,compress=no,vpref=col,vlen=40);

xlsheets.sas       - Get a list of sheet names (topics) from an Excel spreadsheet
                     using DDE and write them to a global macro variable.

                     Usage: %xlsheets(C:\Mydata\Spread Sheet Name.xls);

xpt2sas.sas        - Convert all the .xpt files in a folder to sas datasets

                     Usage: %xpt2sas(%nrstr("V:\SAS\Two Parts\X&Y\"),
                     %nrstr("V:\SAS\Two Parts\X&Y\temp\"));

yrcutoff.sas       - To set the year cutoff option to a number of years previous to the
                     current year. 90 is the default which is suitable for clinical
                     reporting.

                     Usage: %yrcutoff
 

zerogrid.sas       - To create a "grid" of combined values with a variable set to zero
                     for all combinations of values.

                     Usage: %zerogrid(dsout=grid,var1=subject,ds1=demog,var2=tmtarm,
                     ds2=demog,zerovar=count,sortby=tmtarm subject)
                     %zerogrid(zerovar=str,zero="  0 (  0.0)",var1=trtrand ddose,
                     ds1=period1,var2=day,ds2=period1)


 
 


 

Use the "Back" button of your browser to return to the previous page