BookmarkSubscribeRSS Feed
mantubiradar19
Quartz | Level 8

I have two sas datasets which looks as below

 

1.

id A B C D E

 

2.

id B A C E D 

 

How can I combine these two datasets, here my variables are not in same as you can see above. 

 

I would like to combine these two into one datset. 

7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Irrespective of position, when the PDV executes, it creates in memory one variable for each one found in the contributing tables, if the same appears twice then you will get errors.  There are several methods to get what you want, but they all require some sort of renaming or re-populating to variables with a different name.  So say A is your linking variable you could do:

data want;
  set have1 have2 (rename=(b=b1 c=c1 d=d1 e=e1));
  by a;
run;
mantubiradar19
Quartz | Level 8
Thank you very much RW9! Let me try this!
mantubiradar19
Quartz | Level 8

What is my variable name is like ABC123? 

Kurt_Bremser
Super User

You can rename to any valid SAS variable name

- maximum of 32 characters

- must start with a letter or underline

- can contain letters, underlines and numbers

mantubiradar19
Quartz | Level 8
Got it KurtBremser! Thanks a lot
mantubiradar19
Quartz | Level 8
I run this code and I get a dataset with observations of dataset1 and 2 combined and also I have variable columns combined!

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 7 replies
  • 1012 views
  • 0 likes
  • 3 in conversation