BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

 

I have an existing dataset with five variables (5 columns)

 

Three of those columns are already filled up with data.

 

If I have the data for the two empty columns in another dataset, how can we transfer the data from one dataset to the other without using a join or macro value in the case we don't have a key to do a by statement?

 

Suppose that the values of var2 (numeric) and those of var5 (characters) are in another dataset by that there is not sustainable key to make the join.  Please note that the incomplete dataset may have only few observations, let's say, not more than 10.

 

How can we do that task?

Regards,

Alain

 

Ex:

 

 

var1     var2      var3    var4    var5

AN1      1                       AP

AN2      6                       AD

AN3      8                       EP    

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Provide an example, how do you know where the observations go.  Can that be translated into any logical sense?  If you know the position, then add a variable into both datasets, and manually input that position into the datasets, then merge on that id.  Its impossible to answer a question like: "I have some data, I know it, you fix it for me".

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Sorry the question is nonsense.  If there is no link between table 1 and table 2 how do you, using any process known to man, expect to put one into the other?  There has to be some sort of link between data, even if that link is only logical record position in the data.  Also, post clear test data in the form of a datastep and show what the output should look like, this would clearly show what you require.

alepage
Barite | Level 11

I agree with you but imagine that you don't have any key to make the join but you know the position of the values you want to pick from dataset1 and you know the position where the values should go in dataset2.

 

I will never do that for a large dataset but what can we do in the case we have few values to transfert.

Astounding
PROC Star

To get a solution,  you really need to describe what you want in a little more detail.

 

Do both data sets contain the same number of observations?

 

If so, do you want to match them up (first observation in one data set, matching first observation in the other data set, etc.)?

 

If not, how do you want to match them up?

 

You illustrated the first data set.  Now illustrate the second one, and show the result that you would like to achieve.

alepage
Barite | Level 11

The second dataset may look like that

 

17 15
20 21
16 17

 

The values of the first column (dataset2) goes in var3 (dataset1) and the values of the second column (dataset2) goes in var5 (dataset1) .

Consider the possibility that the second line (dataset2) is selected first (to go at the first line in dataset1) then the first line (dataset2) go at the second line of dataset1 and  finally the last line of dataset2 goes at the end of dataset1.

 

I am looking for a solution but only with very small dataset (max observations = 10 and few variables)

 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Provide an example, how do you know where the observations go.  Can that be translated into any logical sense?  If you know the position, then add a variable into both datasets, and manually input that position into the datasets, then merge on that id.  Its impossible to answer a question like: "I have some data, I know it, you fix it for me".

ballardw
Super User

Provide 2 input data sets in the form of datasteps and what the result for those two should be.

 

From what you have provided so far we don't even know the types of variables involved. It may well be that the variables in data set 2 are character and cannot be placed into the numeric variables in data set 1 without manipulation.

sas-innovate-2024.png

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.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 6 replies
  • 687 views
  • 1 like
  • 4 in conversation