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

Hi everyone,

I've got two datasets...

data new;
input no week locf;
datalines;
1 0 0
1 3 0
1 6 0
1 0 1
1 3 1
1 6 1
1 0 2
1 3 2
1 6 2
2 0 0
2 3 0
2 6 0
2 0 1
2 3 1
2 6 1
2 0 2
2 3 2
2 6 2
;
run;


data new2;
length class $10.;
input no week class;
datalines;
1 0 a
1 3 a
1 6 a
1 0 b
1 3 b
1 6 b
1 0 c
1 3 c
1 6 c
2 0 a
2 3 a
2 6 a
2 0 b
2 3 b
2 6 b
2 0 c
2 3 c
2 6 c
;
run;

I would like to obtain it:...but I need some help...thanks V.

1 0 0 a

1 3 0 a

1 6 0 a

1 0 1 a

1 3 1 a

1 6 1 a

1 0 2 a

1 3 2 a

1 6 2 a

1 0 0 b

1 3 0 b

1 6 0 b

1 0 1 b

1 3 1 b

1 6 1 b

1 0 2 b

1 3 2 b

1 6 2 b

1 0 0 c

1 3 0 c

1 6 0 c

1 0 1 c

1 3 1 c

1 6 1 c

1 0 2 c

1 3 2 c

1 6 2 c

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

More robust :

proc sql;

create table want as

select * from new natural join new2;

quit;

PG

PG

View solution in original post

4 REPLIES 4
PGStats
Opal | Level 21

Simplest, but fragile (relies on exact correspondence between the datasets) :

data want;

set new;

set new2;

run;

PG

PG
michtka
Fluorite | Level 6

sorry PGStats....the non sql procedure is not right:  

                               1     1      0       0       a

                                  2     1      3       0       a

                                  3     1      6       0       a

                                  4     1      0       1       b

                                  5     1      3       1       b

                                  6     1      6       1       b

                                  7     1      0       2       c

                                  8     1      3       2       c

                                  9     1      6       2       c

                                 10     2      0       0       a

                                 11     2      3       0       a

                                 12     2      6       0       a

                                 13     2      0       1       b

                                 14     2      3       1       b

                                 15     2      6       1       b

                                 16     2      0       2       c

                                 17     2      3       2       c

                                 18     2      6       2       c

PGStats
Opal | Level 21

More robust :

proc sql;

create table want as

select * from new natural join new2;

quit;

PG

PG
michtka
Fluorite | Level 6

Brilliant, proc sql works.

I think with not proc sql more manipulation is required for thiis kind of many-many merge I think.

Thanks a lot.

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 1032 views
  • 0 likes
  • 2 in conversation