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

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
  • 2 replies
  • 724 views
  • 0 likes
  • 3 in conversation