1 / 13

Manage Variable Lists with Macro Variables

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.

napua
Télécharger la présentation

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Manage Variable Lists with Macro Variables for Improved Readability and Modifiability 1

  2. The Problem/Opportunity • Lists of variables occur frequently • Hard for others to read/verify • Samenesses/differences not apparent • Often have sublists and variations

  3. 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

  4. 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

  5. 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

  6. Assign the Lists %let cateVars=race gender region prevCancer stage grade insur; %let contVars=age BMI dateDiag income; ... 6

  7. Example Code • Title1 Explore distributions of independent variables; • procfreqdata=ChemoData; • table&cateVars /missing; • ...; • procunivariatedata=ChemoData; • var&contVars; • histogram; • ... 7

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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

  13. For More Information David.Abbott@va.gov

More Related