Dear RW, sorry but I am getting confuse, let me do a short recap: 1. DC.Input_analysis_res is created as a result of a proc contents (in this case of the file in.test) proc contents data=in.test out=DC.input_analysis noprint ;run; 2. some variables are dropped and other renamed: proc sql; create table DC.input_analysis as select (cats(trim(t.LIBNAME),trim(t.MEMNAME),trim(t.NAME))) as unique_ID_data_checks ,t.LIBNAME as library_name ,t.MEMNAME as data_set_name ,t.NAME as variable_name ,t.FORMAT ,t.LENGTH ,t.NOBS as observation_number ,t.MODATE as Last_Modified_Date from DC.input_analysis t ;run; 3. the following vatiables are added (e.g Variable_value_list) using an external data source: proc sql; create table DC.input_analysis as select t.* ,t1.Variable_Name_Original ,t1.Variable_Name_English ,t1.Variable_description /* variable description */ ,t1.Variable_value_list /* possible values (not comma separated!!!!!!) */ ,t1.Default_value ,t1.Variable_category /* Classification: date, amount, ID, key */ ,t1.Variable_min /* lower bound */ ,t1.Variable_max /* upper bound */ from DC.input_analysis t left outer join In.Variables_information t1 on (t.variable_name=t1.Variable_Name_Original or t.variable_name=t1.Variable_Name_English) ;run; 4. run the proc means and get already for the numeric variable in test the following information: proc means data=in.test STACKODS n nmiss range min max; var _numeric_; ods output summary=DC.stacked ;run; 5.Create the table DC.input_analysis_res where: the data from input analysis are taken and enhanced with the ones from DC.stacked and additionally 3 new variable are created (in bold): proc sql; create table DC.input_analysis_res as select t1.*, t2.*, 0 as outliers_up, 0 as outliers_down, " " as Unexpected_values from DC.input_analysis t1 left outer join DC.stacked t2 on t1.variable_name=t2.Variable ;quit; Till the point 5 everything is running smoothly. Now I should perform some checks that the command STACKODS was not able to do. For instance: find the value for each observation in DC.input_analysis_res, on the basis of Variable_value_list I would like to fill the variable Unexpected_values. How?Taking each observation of the variable variable_name in DC.input_analysis_res as variable in in.test and comparing the value of all observation for each variable with the value list given in DC.input_analysis_res (field Variable_value_list). In order to get what I want at the point 5, the macro you suggested seems to be the (almost) the perfect solution: %macro In_list (var=,vals=); Options nomacrogen NoSymbolgen nomlogic nomprint nomfile; proc sql; insert into DC.input_analysis_res select distinct "Unexpected_values", variable_value_list in.test where &VAR. not in (&VALS.); quit; %mend In_List; data _null_; set DC.input_analysis_res; if Variable_value_list ne "" then call execute('%In_List (var='||strip(var)||',vals='||strip(variable_value_list)||');'); run; Coming back to your question: in in.test there is no variable named Variable_value_list (this was the input and it should remanin unchanged, the value list is given for each variable by all the observations). in DC.input_analysis_res there is the variable Variable_value_list since it was taken as enahncement (left outer join) if the name would be worng, I would not get it in DC.input_analysis_res. Did we have the same understanding of the same Situation? Thanks a lot RW9.
... View more