Attached an extraction from DC.input_analysis_res
Hi,
Well, I am not writing it for you. Here is an example using sashelp.class and a input dataset. Basically the idea is from your test metadata, to generate a call out to one of the test macros. You can have as many test macros, or calls to them as you like:
data input_analysis_res; length variable_name_original variable_list variable_min variable_max $200; variable_name_original="NAME"; output; variable_name_original="SEX"; variable_list="M F"; output; variable_list=""; variable_name_original="AGE"; variable_min="14"; variable_max="20"; output; variable_name_original="HEIGHT"; variable_min="57"; variable_max="63"; output; variable_name_original="WEIGHT"; variable_min="90"; variable_max="120"; output; run; proc sql; create table RESULTS (VAR char(200),TEST char(200),ID char(200),VAL char(200)); quit; %macro Check_List (ds=,var=,vlist=); proc sql; insert into RESULTS select distinct "&VAR.", "In List", NAME, &VAR. from &DS. where &VAR. not in (&VLIST.); quit; %mend Check_List; %macro Check_Range (ds=,var=,vmin=,vmax=); proc sql; insert into RESULTS select distinct "&VAR.", "Outside Range &VMIN. - &VMAX.", NAME, strip(put(&VAR.,best.)) from &DS. where &VAR. not between &VMIN. and &VMAX.; quit; %mend Check_Range; data _null_; set input_analysis_res; if variable_list ne "" then call execute(cats('%Check_List (ds=sashelp.class,var=',variable_name_original,',vlist="',tranwrd(strip(variable_list)," ",'" "'),'");')); if variable_min ne "" then call execute(cats('%Check_Range (ds=sashelp.class,var=',variable_name_original,',vmin=',variable_min,',vmax=',variable_max,');')); run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.