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.
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;
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.