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

Is there a simple way to repeat the following values for each distinct ID and phase combination? Note: Not all subjects went through all phases.

* Values to Repeat;
data _param00_;
 input paramcd $ paramn @@;
 cards;
	MALINPCR	1	MALINTHK	2	PCRDNS		3
	THKDNS		4	PKPCRDNS	5	PKTHKDNS	6
	FPDNSPCR	7	FPDNSTHK	8	DURPCR		9
 ;
run;

* ID Variables to Add Values to;
proc sql;
 create table _param0_ as
 	select distinct usubjid, aphase
		from phase
		where not missing(avalc) or not missing(aval);
quit; 

I want the resulting dataset to be like:

1  PHASE1   MALINPCR   1

1  PHASE1   MALINTHK   2

1  PHASE1   PCRDNS      3

1  PHASE1  etc.

1  PHASE2   MALINPCR   1

1  PHASE2  etc.

2  PHASE1   MALINPCR   1

2  PHASE1  etc.

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Cartesian join in PROC SQL

 

UNTESTED CODE (because no example data has been provided)

 

proc sql;
    create table want as select a.*,b.paramcd,b.paramn
    from _param0_,param00_;
quit;
--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

Cartesian join in PROC SQL

 

UNTESTED CODE (because no example data has been provided)

 

proc sql;
    create table want as select a.*,b.paramcd,b.paramn
    from _param0_,param00_;
quit;
--
Paige Miller

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

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 637 views
  • 0 likes
  • 2 in conversation