Dear R9, I changed the code as you suggested (here below) /* check 02: macro count outliers */ %macro macro_outliers (var=); proc sql; create table upper_bound as select Variable_max from DC.input_analysis_res where variable_name="&VAR" ;quit; proc sql; create table lower_bound as select Variable_min from DC.input_analysis_res where variable_name="&VAR" ;quit; proc sql; create table base as select distinct "&VAR" from in.test ;quit; proc sql; create table base as select a.*, b.*, c.* from base a, upper_bound b, lower_bound c ;quit; proc sql; create table num_ourliers as select case when &VAR>Variable_max then 1 else 0 end as n_over, case when &VAR<Variable_min then 1 else 0 end as n_under But then I got the following error: proc sql; 2 + create table num_ourliers as select case when 3 + ALTERNATIVEBEGIN>Variable_max then 1 else 0 end as n_over, case when ALTERNATIVEBEGIN<Variable_min then 1 else 0 end as n_under from base ; ERROR: The following columns were not found in the contributing tables: ALTERNATIVEBEGIN. from base ;quit; proc sql; create table num_ourliers as select sum(n_over) as num_over, sum(n_under) as num_under from num_ourliers ;quit; proc sql; update DC.input_analysis_res set outliers_up = (select num_over FROM num_ourliers) where variable_name="&VAR" ;quit; proc sql; update DC.input_analysis_res set outliers_down = (select num_under FROM num_ourliers) where variable_name="&VAR" ;quit; %mend macro_outliers; additional clarification, the variable var works in two ways: 1. search the "variable" as an observation of the variable "variable_name" which is the output of a proc content enhance with some values, in this case the relevant are variable_max and variable_min table example variable_name lenght table ... variable_min variable_max ALTERNATIVEBEGIN ................ 01.01.2015 31.12.2015 gender ..... .............................. - - age ........................................ 18 40 2. search in a table where the variable is really a variable table example: id ALTERNATIVEBEGIN gender age x1 01.01.2014 m 25 x2 02.02.2015 m 50 I would the macro to generate the following output, as enhancement in the table described at variable_name lenght table ... variable_min variable_max outliers_up outliers_down outliers_up ALTERNATIVEBEGIN ................ 01.01.2015 31.12.2015 1 0 gender ..... .............................. - - - - age ........................................ 18 40 0 1 Attached you find a screenshot of the output (I got something but it does nto look meaningful) and in the next post the log I got. Thanks a lot guys!
... View more