Published on :
Général CREATION_INTERNE

Sans titre

This code is also available in: Français Deutsch Español
Data Analysis

Type : CREATION_INTERNE


The macro performs code generation and string manipulation. It does not read any data tables.

1 Code Block
MACRO
Explanation :
Macro definition. It calculates the number of elements via %_count, then loops to generate the content of the when() statement using %_list and %qscan to format each element.
Copied!
1%macro _bwhen/parmbuff;
2 
3%local i j;
4 
5%*put SYSPBUFF=&syspbuff;
6 
7%let j=%_count(&syspbuff, split=%str(,()));
8 
9when(%DO i=1 %to &j;
10 %_list(%qscan(&syspbuff, &i, %str(,())), split=%str(,)) %IF &i<&j %THEN ,;
11%END;)
12 
13%mend _bwhen;
2 Code Block
DATA STEP
Explanation :
Test code (currently commented out) demonstrating the use of the macro in a Data Step to check if an 'hcpcs_cd' variable belongs to a long list of codes or ranges.
Copied!
1/* Exemple de validation (commenté dans la source) */
2DATA _null_;
3 
4 hcpcs_cd='63279';
5 
6 select(hcpcs_cd);
7 %_bwhen('22100', '22110', '22318', '22319', '22326', '22548',
8 '22590', '22595', '61343', '63180', '63182', '63194', '63196', '63198',
9 '63250', '63265'-'63285', '63300', '63304') ex15=1;
10 otherwise;
11 END;
12 
13 put ex15=;
14RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright (c) 2013 Rodney Sparapani