below code checks if the values of exported_dsn and outdsn are not matching if they are not matching then print the non matching observations.
%macro grp_key(lib=,lib2=,varlist=,indsn=,exported_dsn=,outdsn=,result_dsn=); %local key hash ; proc sql noprint; select distinct catx(".",libname,memname) into: key separated by " " from dictionary.columns where libname ="&lib" and findw("&varlist",strip(name), ' ','i')>0; quit;
%put &key;
data &indsn; set &key; run;
data &indsn; set &indsn; merge_key= _n_; run; proc sql noprint; select distinct catx(".",libname,memname) into: hash separated by " " from dictionary.columns where libname ="&lib2" and findw("&varlist",strip(name),' ','i')>0; quit;
%put &hash;
data &exported_dsn; set &hash; run;
%let newvarlist=; %do i=1 %to %sysfunc(countw(&varlist)); rename %scan(&varlist,&i)=%scan(&varlist,&i).str; %let newvarlist=&newvarlist%scan(&varlist,&i).str; %end;
data &exported_dsn; set &exported_dsn; merge_key=_n_; rename &varlist =&newvarlist; run;
data both; merge &indsn &exported_dsn; by merge_key; run; PROC SORT DATA = both OUT = &outdsn NODUPKEY; BY &varlist &newvarlist; RUN;
PROC FREQ DATA=&outdsn; TABLES &varlist*&newvarlist / noprint nopercent out=&outdsnfreq; run;
proc sort data = &outdsnfreq nodupkey; by &varlist &newvarlist; run;
data &outdsnfreq; set &outdsnfreq; by &varlist &newvarlist; if first.&varlist ne last.&varlist then do; error = 1; output; end; run;
proc print data = &outdsnfreq; var &varlist &newvarlist; run;
%mend grp_key;
%grp_key(lib=GRP,lib2=GKEY, varlist= name height,indsn=team1,exported_dsn=teams2,outdsn=total1,result_dsn=Gkey);
NOTE: Line generated by the macro variable "VARLIST". 1 name height ------ 79 ERROR 79-322: Expecting a -.
NOTE: Line generated by the macro variable "NEWVARLIST". 1 name.strheight.str ------------------ 24 ERROR: Missing numeric suffix on a numbered variable list (name-height). ERROR: Invalid variable specification, name.strheight.str. Variable names of the form X.X must be either FIRST.X or LAST.X. MPRINT(GRP_KEY): rename name height =name.strheight.str ; ERROR: Old and new variable name specifications for RENAME must be of the same type. Statement is ignored. MPRINT(GRP_KEY): run;
ERROR 24-322: Variable name is not valid
both libs hav 1 ds in them each with name height ID as columns in them, above code is appending data of indsn & exported_dsn and its merged in both dataset. in the proc compare am checking if values of both dataset are equal. But code gives error for &varlist.str and it doesnot check the specific each value from exported_dsn is matching to &outdsn.
How can i check if all exact specific values from exportdsn matc outdsn .....
... View more