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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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