Hi,
I want to compare variable of table1 with table2. If discrepancy found, store it in a new dataset with a comment. After that, compare each variable value from table1 with variable value of table2. If found mismatch, stored in new dataset.
Expected Output
comment variable missing for table2
length-ename-emp
length-hdate-HR
label-dname-Dept
data table1; input dataset $ variable $ label $ datatype $ length $ comment $; datalines; Emp ename empname char 40 . Emp job job char 20 . Emp sal salary char 20000 . Dept dname deptname char 10 . HR hdate hiredate date date9 . ; run; data table2; input dataset $ variable $ label $ datatype $ length $; datalines; Emp ename empname char 48 Emp job job char 20 Emp sal salary char 20000 Dept dname dept char 10 HR hdate hiredate date date9. ; run;
Use PROC COMPARE:
proc sort data=table1;
by dataset variable;
run;
proc sort data=table2;
by dataset variable;
run;
proc compare
base=table1
compare=table2
listvar
out=comp
;
id dataset variable;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.