BookmarkSubscribeRSS Feed
Jyuen204
Obsidian | Level 7

I have 2 tables
Table 1 has data that will get refreshed daily so 1 day could have 3 records, next day could have 5

Table 2 has 250 static values 

 

I want to update Table 1 with a value for each row from Table 2. Table 2 has no matching value to Table 1. I just want to assign one of the values to each record in Table 1

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Can you give us a small example so we can see what you want?

--
Paige Miller
ballardw
Super User

@Jyuen204 wrote:

I have 2 tables
Table 1 has data that will get refreshed daily so 1 day could have 3 records, next day could have 5

Table 2 has 250 static values 

 

I want to update Table 1 with a value for each row from Table 2. Table 2 has no matching value to Table 1. I just want to assign one of the values to each record in Table 1


Do you want some random value from table 2? Any value? Does it have to be the same or forced to be different on day 2 than on day 1?

Does each row of set 1 get the same or do the values from table 2 have to be different?

 

You might describe what the value of this added variable might have if there isn't a match and you don't seem to care what the value added might be.

Jyuen204
Obsidian | Level 7

Here is an example. So Table1 is the daily list of records that can vary day to day. This example has 3 records (Cust1, Cust2, Cust3). I want to assign a value from Table2.CODES to Table1.CODES. 

 

data table1;
Length CustID $5;
input CustID $ CODES;
datalines;
Cust1
Cust2
Cust3
run;

data table2;
input CODES;
cards;
123
456
789
101
111
121
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 903 views
  • 0 likes
  • 3 in conversation