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

TABLE 1.

Student | Math | English | Science

Sue           3.5        6.0          2.1

Amy          3.7        5.3          2.8

Cindy        2.9        5.8          3.5

Kevin        3.2        6.2          2.1

 

TABLE 2.

Math National Avg | English National Avg | Science National Avg

                       3.6                             6.1                               3.8

 

TABLE WANT

Student | Math | English | Science | Math National Avg | English National Avg | Science National Avg

Sue           3.5        6.0          2.1                            3.6                              6.1                              3.8

Amy          3.7        5.3          2.8                            3.6                              6.1                              3.8

Cindy        2.9        5.8          3.5                            3.6                              6.1                              3.8

Kevin        3.2        6.2          2.1                            3.6                              6.1                              3.8

 

I want to combine table 1 and table 2 to create table want. I don't know how to combine tables without an unique idenitifier. Someone please help. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Data want;
If _n_ = 1 then set table2;

Set table1;

Run;

Try this. 

View solution in original post

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Something like this (not tested - for tested code post test data in the form of a datastep):

data want;
  merge table1 table2;
run;
ernie86
Calcite | Level 5

I already tried this, and it didn't work. It came out like this:

Student | Math | English | Science | Math National Avg | English National Avg | Science National Avg

Sue           3.5        6.0          2.1                           

Amy          3.7        5.3          2.8                          

Cindy        2.9        5.8          3.5                         

Kevin        3.2        6.2          2.1                           

                                                                                3.6                              6.1                              3.8

Reeza
Super User
Data want;
If _n_ = 1 then set table2;

Set table1;

Run;

Try this. 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

This shold work:

data a;
  a=1; output;
  a=2; output;
run;
data b;
  c=1;
run;
proc sql;
  create table WANT as
  select *
  from   A
  full join B
  on     1=1;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1104 views
  • 0 likes
  • 3 in conversation