Programs are the transformation of rules into computer language. No rule, no program.
Let's assume your table1 would also have an ID of 10. Which row/value from the existing table2 would you pick? And why?
table1;
Id weight 1 22 2 18 3 23 4 19 5 12 6 20 7 22 8 20 9 12
table 2:
Id height . 76 . 45 . 23 9 11 8 12 4 89 3 43 2 66 1 34
Code I have used is,
data table3;
merge table1(in=x) table2(in=y);
by id;
IF y;
run;
my output expectation is :
Id height weight 5 76 12 <- What was the rule for this? 6 45 20 7 23 22 9 11 12 8 12 20 4 89 19 3 43 23 2 66 18 1 34 22
How did you decide that the first record in Table 2 would be ID 5?
On which rule is your assumption based? Without a rule, there will be no programmatic solution, and you can use a random generator or just throw the dice.
@Naveen1 wrote:
It's just assumption (that is how I was expecting output).
We're not in your head. We see only exactly what you post. A computer can only do what you tell it. So what are you telling it to do?
As someone else stated earlier, you need rules to turn into coded logic. Right now it just seems random, so is that ok randomly assigning the values? Is it ok to have the following output? If not, how do *I*, not you, know it's wrong? Is there a rule. If the rule is only in your head, the only solution is to literally type out each rule manually.
Is this output ok?
Id | height | weight |
5 | 23 | 12 |
6 | 45 | 20 |
7 | 76 | 22 |
9 | 11 | 12 |
8 | 12 | 20 |
4 | 89 | 19 |
3 | 43 | 23 |
2 | 66 | 18 |
1 | 34 | 22 |
Why did you match ID=., HEIGHT=76 with ID=5, WEIGHT=12 instead of matching it to one of the other weight records there were not in the height file? ID=6 or ID=7?
no need of solution, it has some mistake in the question
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.