daboulifard.com

Home     Research     Software

 

 

Software 

Excel

SAS

 

 

 

   Excel

Data Dictionary Workbook

Data_Dict.xls is a data dictionary template.  The workbook you create from it contains information that explicitly describes file contents.  If you can use Excel to search, sort, and filter worksheet data, you can use this information to facilitate your management of complex files and increase your coding efficiency.

 

 

 

 

 

 

SAS

Project Startup Program

Project_Start.sas is a startup program template.  The program you create from it configures the SAS session environment for a project.  It specifies directories and libraries in a way that facilitates portability, and runs programs that install utility macros.

Utility Macros

These programs install utility macros.  Each installs one macro, using its name root as the macro's name; for example, replace.sas installs replace.  The program begins with a comment section that describes the macro and illustrates its use.

String Manipulation

The macro replace searches a text string to replace each occurrence of one character sequence with another character sequence.

List Manipulation

These macros treat a text string as a list of items separated by delimiter characters.  Ordinarily, items are names, name-prefixes, name-suffixes, or numbers, whereas delimiters are blanks; but other schemes are possible:

 

%let MyVars = V01 V02 V03 V04; * names delimited by blanks;

%let MyTabs = a*b | a*c | b*c; * crosstab requests delimited by vertical bars;

 

Some of these macros create, describe, or maintain lists:

 

integers

generate integer sequence                 

count

count items

delimit

replace delimiter with character

comma

replace delimiter with comma

catenate

concatenate lists

unique

remove duplicate items

 

Others compare or combine lists:

 

set_dif

obtain set difference

set_dsm

obtain set difference (symmetric)

set_int

obtain set intersection

set_uni

obtain set union

 

These macros facilitate many activities involving name lists.  For example, you could generate the name sequence V01 V02 ... V12 as follows:

 

%let MyVars = %catenate(V, %integers(12));

 

You could also specify a list of drop variables from lists of all and keep variables, as follows:

 

%let DropVars = %set_dif(&AllVars., &KeepVars.);

List Processing

The macro loop performs a task once for each item in a delimited list, or each pairing of items from two such lists.  You specify the task in a line of SAS code, which serves as a template.  Your code refers generically to an item via the macro variable x, or to a pair of items via the macro variables x and y.  When you call loop, it runs each item or pair of items in turn through the template.  SAS will treat any text this processing generates as if you had coded it in place of the call to loop.

 

The flexibility with which you can specify tasks and item lists in a variety of contexts gives loop a wide range of applications.  For example, you could generate the name sequence V01 V02 ... V12 as above, without using catenate, as follows:

 

%let MyVars = %loop(%nrstr( V&x.), %integers(12));

 

You could also create log-transformed versions of data set variables A, B, and C as follows:

 

%macro trfm;

Log_&x. = log(&x.);

%mend;

 

data mydb2;

set  mydb1;

%loop(%nrstr(%trfm), A B C)

run;