Manage variable lists with macro variables
This presentation is the property of its rightful owner.
Sponsored Links
1 / 13

Manage Variable Lists with Macro Variables PowerPoint PPT Presentation


  • 52 Views
  • Uploaded on
  • Presentation posted in: General

Manage Variable Lists with Macro Variables. for Improved Readability and Modifiability. 1. The Problem/Opportunity. Lists of variables occur frequently Hard for others to read/verify Samenesses /differences not apparent Often have sublists and variations. Proposed Solution.

Download Presentation

Manage Variable Lists with Macro Variables

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Manage variable lists with macro variables

Manage Variable Lists with Macro Variables

for Improved Readability

and Modifiability

1


The problem opportunity

The Problem/Opportunity

  • Lists of variables occur frequently

  • Hard for others to read/verify

  • Samenesses/differences not apparent

  • Often have sublists and variations


Proposed solution

Proposed Solution

  • Assign each sublist to a macro variable

  • Name the macro variables informatively

  • Use as needed in executable code

  • Manipulate macroed string for alterations


Example code

Example Code

  • Title1 Explore distributions of independent variables;

  • procfreqdata=ChemoData;

  • tablerace gender region prevCancer stage grade insur/missing;

  • ...;

  • procunivariatedata=ChemoData;

  • varage BMI dateDiag income;

  • histogram;

  • ...

4


Example code 2

Example Code (2)

Title1 Check for multicolinearity;

procregdata=ChemoData;

model chemoRecvd = age BMI dateDiag income/vif;

Title1 Perform logistic regression;

proclogisticdata=ChemoData simpledesc;

classrace gender region prevCancer stage grade insur /param=ref desc;

model chemoDi = race gender region prevCancer stage grade insur age BMI dateDiag income/scale=none rsqlackfit;

5


Assign the lists

Assign the Lists

%let cateVars=race gender region prevCancer stage grade insur;

%let contVars=age BMI dateDiag income;

...

6


Example code1

Example Code

  • Title1 Explore distributions of independent variables;

  • procfreqdata=ChemoData;

  • table&cateVars /missing;

  • ...;

  • procunivariatedata=ChemoData;

  • var&contVars;

  • histogram;

  • ...

7


Example code2

Example Code

Title1 Check for multicolinearity in continuous IVs;

procregdata=ChemoData;

model chemoRecvd = &contVars /vif;

run;

Title1 Perform logistic regression;

proclogisticdata=ChemoData simpledesc;

class&cateVars /param=ref desc;

model chemoDi = &cateVars &contIndVars /scale=none rsqlackfit

8


Handling alterations variations

Handling Alterations/Variations

  • Change the number of categories used for a variable

  • Drop uninformative variables

  • Add variables for portion of analysis

  • => Can do all of these without cut/paste

  • => Can make the alterations explicit


Replacing a variable

Replacing a Variable

%macro replaceWord( /*in macro string */

inStr=, /*list of words altered*/

swapOut= /*word replaced list*/,

swapIn=, /*replacement word*/

resMacVar= /*macvar receiving result*/

);

%let newList=; *Use just 2 race categor;

%replaceWord(inStr=&cateVars,swapOut=race , swapIn=race2c, resMacVar=newList);

10


Removing variables

Removing Variables

%macro removeWords(

wordList=, /*words to remove*/

inMacVar=, /*list of words to alter*/

outMacVar= /*result list of words*/

);

%let newList=; *Drop uninformative vars;

%removeWords(wordList=race insur,

inMacVar=cateVars, outMacVar=newList);

11


Take aways

Take Aways

Just do it!

Long list of vars need occur only once

Readability benefits when lists are named

Modifiability benefits when occur only once

Both benefit when alterations are explicit


For more information

For More Information

[email protected]


  • Login