SAS Documentation
SASĀ® Solution for Stress Testing
Reference manual - version 08.2021
Loading...
Searching...
No Matches
irm_get_vars_where_cond.sas
1%macro irm_get_vars_where_cond( ds_in=
2 ,where_vars_col =
3 ,var_list =
4 );
5/* Parse through where_vars_col to get a list of variables referenced in all the where condition */
6data _null_;
7 set &ds_in. end=last;
8 retain src_keep ;
9 length src_keep $3000 ;
10 /* For each var in the where_vars_col */
11 do i=1 to countw(&where_vars_col.," ");
12 put i=;
13 if i eq 1 and _N_ eq 1 then do;
14 src_keep=scan(&where_vars_col.,1," ");
15 end;
16 else do;
17 if i eq 1 then do;
18 temp=scan(&where_vars_col.,i," ");
19 if findw(src_keep,temp,' ','R')=0 then do;
20 src_keep=catx(" ",src_keep,temp);
21 end;
22 end;
23 else do;
24 /* Extract each variable name from the list of vars and store in source keep (if not already stored) */
25 temp=scan(&where_vars_col.,i," ");
26 temp=scan(temp,-1," ");
27 if findw(src_keep,temp,' ','R')=0 then do;
28 src_keep=catx(" ",src_keep,trim(temp));
29 end;
30 end;
31 end;
32 end;
33 /* Store the list of variables to keep in the var_list macro variable */
34 if last then do;
35 call symputx("&var_list.",trim(src_keep));
36 end;
37run;
38%mend;