DATA Step, Macro, Functions and more

How to check in new variable is added

Reply
Super Contributor
Posts: 673

How to check in new variable is added

how to check if a new variable(s) is added to the dataset and check the values of existing variables with previous month dataset.
for instance:
there is a dataset zip with the following variables:
zip RDT5 RDT17 RDT23 RDT51

next month RDT75 is added.How to check if new variable is added. and check the values of RDT5 RDT17 RDT23 RDT51 are the same as previous month.

I'm limiting the number of variables only to 5.but in actuality there are 50 variables.
also RDT doesnt contain continous suffix.
Valued Guide
Posts: 2,177

Re: How to check in new variable is added

proc compare will compare structure as well as data
Super Contributor
Super Contributor
Posts: 365

Re: How to check in new variable is added

Hello SASPhile,
This code checks if a new variable has been added to dataset WORK.I compared to WORK.R:
[pre]
proc SQL;
select name into :l0 separated by ' '
from sashelp.vcolumn where LIBNAME="WORK" and memname="I"
;quit;
proc SQL;
select name into :l1 separated by ' '
from sashelp.vcolumn where LIBNAME="WORK" and memname="R"
;quit;
options nosymbolgen;
%put l0=&l0;
%put l1=&l1;
%let d=%EVAL(%LENGTH(&l1)-%LENGTH(&l0));
[/pre]

To check if old variable values have been changed it is good to use suggested proc COMPARE with base=Old dataset Compare=New dataset subsetted to contain old variables only.
HTH, SPR
Ask a Question
Discussion stats
  • 2 replies
  • 129 views
  • 0 likes
  • 3 in conversation