BookmarkSubscribeRSS Feed
SP01
Obsidian | Level 7

Hello SAS Community,

 

I have a problem where I would appreciate your help.

 

My working dataset A has the following information. I am just adding few rows so that you know the issue.

 

Working dataset A (165 rows)

Gender Race  Ethnicity          County

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

 

Census dataset B (265 rows, will need to insert 100 rows from this to above dataset to balance to 265)

Gender Race  Ethnicity          County

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

M         Black  Non-hispanic    Lincoln

Lets say I have 165 rows with this combination in working dataset.

 

From our dataset B which is our census population, we have 265 rows with the above combination. So, to balance and insert population into the dataset A,

I need to add 100 rows with this combination from dataset B to  dataset A. 

 

I have create IDs for rows using gender, race, ethnicity, county and the same thing in census population and tried to join them on these combinations. But it didn't work.

 

I am not sure how to move forward, please help.

 

Thank you!

1 REPLY 1
ballardw
Super User

Are there any variables that appear in B that do not appear in A? Are there any variables in A that do not appear in B?

If not it appears that you just replace A with B to have the numbers match. So I suspect there are details you are leaving out.

 

I would suspect additional variables like age, or age group, as well to be somewhere from the Census data I have worked with.

 

"Didn't work" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the "</>" to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "</>" icon or attached as text to show exactly what you have and that we can test code against.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1 reply
  • 516 views
  • 0 likes
  • 2 in conversation