Hi all! For a project I am building a data quality checking framework. I have a table containing ~100 different variable names, and their allowed values and subsequently have to check if all values are within these (discrete) allowed values. My end goal is to have a flag for each variable indicating if all values are within the allowed set of values. I know this is not very common, but I was trying to solve this by implementing an SQL query within a datastep in the following way. DATA WANT; set HAVE; call symputx('var_to_check', NAME); /* Creating global variable to pass to the sql query */ call symputx('allowed_vals', allowed_vals_str); PROC SQL; SELECT DISTINCT count(&var_to_check.) INTO :var_count FROM HAVE2 WHERE &var_to_check. NOT IN (&allowed_vals.) ;QUIT; N = &var_count; RUN; Now the SQL query seems to work, but only for one variable.. Does it 'break out' of the datastep when being run? And are their other, more efficient ways of implementing this? I am quite new to SAS.. Thank you! EDIT: I see I should have provided some data to make it more clear, sorry - quite new to SAS.. This is approximately what I want: data HAVE; infile datalines delimiter='|'; length NAME $9; length AllowedValues $5; input NAME $ AllowedValues $; datalines; Confirmed_Status|{0,1} Remidiation_Flag|{0,1} ; data HAVE2; infile datalines delimiter='|'; input Confirmed_Status $ Remidiation_Flag $; datalines; 0|1 1|0 0|0 0|0 1|0 2|0 0|0 ; data WANT; infile datalines delimiter='|'; length NAME $9; length AllowedValues $5; input NAME $ AllowedValues $ Flag; datalines; Confirmed_Status|{0,1}|1 Remidiation_Flag|{0,1}|0 ;
... View more