BookmarkSubscribeRSS Feed
Dhana18
Obsidian | Level 7

Please please tell me what is wrong with this code. it is not working. 

 

/*Merging visit and std elements datasets by unique id*/
data JanFeb_COMPLETE_2019;
merge janfebs.CONCATENATE_JAN2FEB_2019(in=A) CONCATENATE_KEENAN_CLN19(in=B);
by UNIQUE_ID;
If a and b;
run;

 

the log says 

3142 data JanFeb_COMPLETE_2019;
3143 merge janfebs.CONCATENATE_JAN2FEB_2019(in=A) CONCATENATE_KEENAN_CLN19(in=B);
3144 by UNIQUE_ID;
3145 If a and b ;
3146 run;

NOTE: There were 702 observations read from the data set JANFEBS.CONCATENATE_JAN2FEB_2019.
NOTE: There were 79 observations read from the data set WORK.CONCATENATE_KEENAN_CLN19.
NOTE: The data set WORK.JANFEB_COMPLETE_2019 has 0 observations and 69 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

6 REPLIES 6
Astounding
PROC Star
Your program contains this line:

if a and b;

Do you understand what this does?

There are no values of UNIQUE_ID that appear in both incoming data sets.
Dhana18
Obsidian | Level 7
My understanding is if records are in A and in B. Is that what it is?
Dhana18
Obsidian | Level 7

I just checked

There are values of UNIQUE_ID that appear in both incoming data sets I just checked.

It works if I say if a  or if b but it just does not work when I say if a and b.

Dhana18
Obsidian | Level 7

Please help me to figure out what is wrong in this code. I am trying to merge data from two data sets if the records are in both data sets.

 

data JanFeb_COMPLETE_2019;
merge CONCATENATE_KEENAN_CLN19 (in=B) janfebs.CONCATENATE_JAN2FEB_2019(in=A);
by UNIQUE_ID;
If a and b;
run;

 

Astounding
PROC Star
You will need to check the values more carefully. They do not match. Perhaps some of them have leading blanks. Perhaps some of them contain a tab character at the end. But they do not match.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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