BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Sir_Highbury
Quartz | Level 8

Attached an extraction from DC.input_analysis_res

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 16 replies
  • 2173 views
  • 1 like
  • 2 in conversation