I have 2 dataset described below name correct data and incorrect data. Now i want to map incorrect data from correct data.
For example in incorrect data for adarsh nagar station circle is incorrect and for harmara station police district is incorrect.
I have used proc sort by station for both the table and then i have used IN= option but it wokrs for just one variable but i want to map data using for both variable i.e. circle and station.
Correct Data | Incorrect data | |||||
District | Circle | Station | District | Circle | Station | |
EAST | ADARSH NAGAR | ADARSH NAGAR | EAST | CHOMU | ADARSH NAGAR | |
EAST | ADARSH NAGAR | JAWAHAR NAGAR | EAST | ADARSH NAGAR | JAWAHAR NAGAR | |
WEST | CHOMU | HARMARA | WEST | CHOMU | HARMARA | |
WEST | CHOMU | VISHWAKARMA | EAST | CHOMU | VISHWAKARMA |
Please show a desired output to further describe your requirement.
Maybe you should slightly change the second condition:
data match mismatch;
merge WORK.CORRECT(in=PC) WORK.INCORRECT(in=PS1 rename=(Circle=Circle1 district=district1));
by station;
if PC;
if district eq district1 and Circle eq Circle1 then output match;
if district ne district1 or Circle ne Circle1 then output mismatch;
run;
or make it even simpler:
data match mismatch;
merge WORK.CORRECT(in=PC) WORK.INCORRECT(in=PS1 rename=(Circle=Circle1 district=district1));
by station;
if PC;
if district eq district1 and Circle eq Circle1
then output match;
else output mismatch;
run;
Please post example data in a data step, like
data correct;
infile cards dlm=',';
input district :$4. circle :$20. station :$20.;
cards;
EAST,ADARSH NAGAR,ADARSH NAGAR
EAST,ADARSH NAGAR,JAWAHAR NAGAR
WEST,CHOMU,HARMARA
WEST,CHOMU,VISHWAKARMA
;
run;
This makes it easier for us to recreate your data.
A macro that does this automatically cam be found at https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.