BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mona4u
Lapis Lazuli | Level 10

data WBC;
input subject $ TRTA $ Amethod $ WBC;
datalines;
1 A Upper 2.2
1 A lower 2.1
;


data QS;
input subject $ TRTA $ QS $ QSVAL;
datalines;
1 A Q1 99
1 A Q2 100
;


proc sort data=wbc; by subject trta; run;
proc sort data=qs; by subject trta; run;

data all;
merge wbc qs;
by subject trta ;
RUN;

 

here is the data that I get 

SUBJECT TRTA AMETHOD WBC QS QSVAL
1 A Upper 2.2 Q1 99
1 A lower 2.1 Q2 100

 

this is what I want 

 

SUBJECT TRTA AMETHOD WBC QS QSVAL
1 A Upper 2.2 Q1 99
1 A Upper 2.2 Q2 100
1 A lower 2.1 Q1 99
1 A lower 2.1 Q2 100
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Use a Cartesian join in PROC SQL

https://support.sas.com/kb/25/270.html

--
Paige Miller

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Use a Cartesian join in PROC SQL

https://support.sas.com/kb/25/270.html

--
Paige Miller
mona4u
Lapis Lazuli | Level 10

created this and it is not working for me. 

PaigeMiller
Diamond | Level 26

@mona4u wrote:

created this and it is not working for me. 


I don't know what to say. You have provided no information from which I can help you.

--
Paige Miller
mona4u
Lapis Lazuli | Level 10

I have multiple treatments and multiple subjects. when I tried that type of merge it is creating some weird results. 

mona4u
Lapis Lazuli | Level 10

I added the where statement and it worked. 

 

 

Thanks

Dianahemes
Fluorite | Level 6

A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.

 

Regards,

Will

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1809 views
  • 1 like
  • 3 in conversation