/
The Six Ampersand Solution John R The Six Ampersand Solution John R

The Six Ampersand Solution John R - PDF document

pamella-moone
pamella-moone . @pamella-moone
Follow
382 views
Uploaded On 2015-04-28

The Six Ampersand Solution John R - PPT Presentation

Gerlach IMS America Plymouth Meeting PA Abstract Assume you want to reinstate macro variables denoting criteria for an analysis that you performed months ago Using Dictionary tables made available through the SQL procedure it is possible to c ID: 55859

Gerlach IMS America Plymouth

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "The Six Ampersand Solution John R" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

John R. Gerlach, IMS America; Plymouth Meeting, PAAbstractAssume you want to reinstate macro variablesdenoting criteria for an analysis that you performedmonths ago. Using Dictionary tables, made availablethrough the SQL procedure, it is possible to collect macrovariables defined for that analysis and to store them in apermanent SAS data set containing the name of each course, it would have been easier to print the contents ofparams data set or, simply, to use the PUT statementin the Data step. However, this paper offers an exercisein the Macro Language, namely, indirect referencing ofmacro variables.The %params macro consists of two parts: aData _NULL_ step and some Macro Language. The Datastep reinstates the macro variables of interest using theSYMPUT routine discussed already. Also, it defines othermacro variables needed to list the reinstated macrovariables using two other SYMPUT routines, one whichcreates the macro variables var1the macro variables being reinstated and the other whichexecutes conditionally, when reading the last observation,thereby creating the macro variable nmvarsthe number of macro variables to be listed. The other partof the %params macro writes the reinstated macrovariables to the SAS log by using the %DO loop and the%PUT statement along with the six ampersand solution.How Indirect Referencing WorksIn order to appreciate the six ampersandsolution, it is important to understand how the macroprocessor resolves macro variables having two or moreampersands.Macro variables having more than oneampersand, called indirect references, require multiplescans by the macro processor. The processor scans anddelimited by a special character or semicolon) until allGiven the following %PUT statement used in the%params macro, assume that one of the macro variablesis DXCODE having the value of 4019 (i.e., the ICD-9 codefor Essential Hypertension).&&var&i.., which denotes the th iteration of the %DOloop statement.For the first iteration of the %DO loop, the macro&&var&i. resolves to whatever the macro&var1. contains, which depends on the contentsparams data set obtained via the Dictionary tableand the CALL SYMPUT statement that created the macro&var1., …, &var in the prior Data step. Thus,&&var&i..&var1.The six ampersand variable (actually seven)resolves in a similar manner, however, it takes severalscans to completely resolve the macro variable. That is,the macro processor reads times), reads and generates the constant text previously. Now, when the processor reaches the end ofthe token (variable), it makes a new scan, proceeding to&&&var1. anew. That is, the&var1. and generates the contents of that macro variable,which is the name of one of the reinstated macrovariables. Finally, the processor resolves the macro&&&&&&var&i..&&&var1.Consequently, the %PUT statement writes thename of each macro variable and its value to the SAS log.Given an application that requires a collection ofcriteria used for processing and reporting, it is important topreserve those criteria in order to replicate or modify ananalysis. Using Dictionary tables, you can store thenames and values of macro variables denoting thecriteria, then recreate them at a later time.The added feature of listing the reinstated macrovariables to the SAS log offers a rigorous exercise in howthe Macro Processor resolves multiple ampersands,called indirect referencing of macro variables.John R. GerlachIMS America600 West Germantown PikePlymouth Meeting, PA 19462-1048610.832.5493SAS is a registered trademark of SAS Institute.