BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
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.
2 REPLIES 2
Peter_C
Rhodochrosite | Level 12
proc compare will compare structure as well as data
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1341 views
  • 0 likes
  • 3 in conversation