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

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

Submit your idea!

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.

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
  • 1 reply
  • 372 views
  • 0 likes
  • 2 in conversation