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

Hi ALL, 

I have some issues with some of the records that I have. 

The stdt and ptnm have multiple values in the same row and I want to split the stdt and ptnm values in multiple records 

 

this is what I currently have

ProtStIDSubIDCRFIDISubIDPACNRevTpVstDtVstIDAERefPtNmLltNmStDt
A3921133A3921133 1134A3921133 1134 113410493409741144893H1604060Consensus09/Feb/2016823129 2 Sequential AST or ALT >= 3x ULN,2 Sequential AST or ALT >= 3x ULN,Liver injury;  03/Mar/2016,14/Mar/2016,09/Feb/2016

 

 

the aimed result 

 

ProtStIDSubIDCRFIDISubIDPACNRevTpVstDtVstIDAERefPtNmLltNmStDt
A3921133A3921133 1134A3921133 1134 113410493409741144893H1604060Consensus09/Feb/2016823129 2 Sequential AST or ALT >= 3x ULN 03/Mar/2016
A3921133A3921133 1134A3921133 1134 113410493409741144893H1604060Consensus09/Feb/2016823129 2 Sequential AST or ALT >= 3x ULN 14/Mar/2016
A3921133A3921133 1134A3921133 1134 113410493409741144893H1604060Consensus09/Feb/2016823129 Liver injury;  09/Feb/2016
1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

So assuming that the ptnm and stdt gets split on commas, you could do something like this:

 

/* UNTESTED CODE */
data want;
    set have;
    record=1;
    do while (not missing(scan(ptnm,record,',')));
        ptnm_new=scan(ptnm,record,',');
        stdt_new=scan(stdt,record,',');
        record=record+1;
        output;
    end;
    drop record ptnm stdt;
run;
        
--
Paige Miller

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

So assuming that the ptnm and stdt gets split on commas, you could do something like this:

 

/* UNTESTED CODE */
data want;
    set have;
    record=1;
    do while (not missing(scan(ptnm,record,',')));
        ptnm_new=scan(ptnm,record,',');
        stdt_new=scan(stdt,record,',');
        record=record+1;
        output;
    end;
    drop record ptnm stdt;
run;
        
--
Paige Miller
Reeza
Super User

@PaigeMiller missing an OUTPUT statement?

PaigeMiller
Diamond | Level 26

@Reeza wrote:

@PaigeMiller missing an OUTPUT statement?


Yes, I was! But that has been corrected now. Thanks!

--
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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 746 views
  • 4 likes
  • 3 in conversation