BookmarkSubscribeRSS Feed
Smitha9
Fluorite | Level 6

Hi,

I have a variable name format

Chicago Michigan Boston Ohio

 

New dataset has the following variable name:

Chicag Michigan Bostor Ohid

I need to compare this dataset with the above formatted variable name and report the errors.

 

Can I code this one?

 

thank you in advance

 

2 REPLIES 2
Kurt_Bremser
Super User

Yes, you can.

 

Use DICTIONARY.COLUMNS (SQL) or SASHELP.VCOLUMN (data step) to compare the variables in both datasets.

e.g.

data check;
merge
  sashelp.vcolumn (in=d1 where=(libname="LIB1" and memname="DS1"))
  sashelp.vcolumn (in=d2 where=(libname="LIB2" and memname="DS2"))
;
by name;
if d1 and d2 then check = "both";
else if d1 then check = "d1";
else check = "d2";
keep name check;
run;
Reeza
Super User
Have you looked into PROC COMPARE?

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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