BookmarkSubscribeRSS Feed
SASAna
Quartz | Level 8

Hi SAS users,

 

I have data coming like this in procedure code field - 1234|2345|4567 for a claim. I want to change make this to multiple lines by splitting the procedure codes pipes.

 

Original data  :

 

clm    procedure_code

1       1234|2345|4567 

 

Needed format :

 

clm  procedure_code

1       1234

1        2345

1        4567

 

Thanks,

Deepa

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20
data have;
input clm procedure_code $30.;
datalines;
1 1234|2345|4567 
;

data want;
   set have;
   do i = 1 to countw(procedure_code, '|');
      p_code = scan(procedure_code, i, '|');
      output;
   end;
   drop procedure_code i;
run;
CarmineVerrell
SAS Employee
Hi Deepa,
Here is a simple solution example if the data that you mentioned is static and always starts and stops in the same position within the original data in procedure_code. If it doesn't then we would need to modify the code to make it more flexible.

data orgdata;
infile cards;
input clm pro_code $14.;

cards;
1 1234|2345|4567
;
run;

Data newfmt(drop=pro_code);
set orgdata;
procedure_code=substr(pro_code,1,4);
output;
procedure_code=substr(pro_code,6,4);
output;
procedure_code=substr(pro_code,11,4);
output;
run;

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
  • 2 replies
  • 484 views
  • 1 like
  • 3 in conversation