BookmarkSubscribeRSS Feed
gbond21
Obsidian | Level 7
data clinical1;
length str $300;
 set clinical;
  by pat_id;
  retain str "";

  if first.pat_id then str=event_res; 
  else str=catx('@',str,event_res); /*Concatenate String and use @ or any other     symbol to identify the Levels*/
  str=TRANWRD(str,'],',']@') ;

  if last.pat_id;
  str="@"||str;

  drop event_res;
run;

I have a dataset that has two variables Pat_ID and STR.

 

The STR variable has multiple values within the cell with each value corresponding to a level. The levels range from 1 to 5 and some cells have contain different values that correspond to the same level.

 

For example PAT_ID ...0250 has two level 3 events vital signs and blood. I would like to create a table that parses out each value based on its level. so PAT_ID 0250 would have two level 3 columns one for vital signs and the other for blood. Thanks for the help!

 

Capture.PNG

4 REPLIES 4
gbond21
Obsidian | Level 7

Thanks all!

 

Not exactly, that code concatenates the columns, I would like this string from the STR column(which is a result from the above code):

 

@Triage and Initial RN Assessment only [level 1]@Blood-peripheral venous [level 3]@Oral meds [level 3]@Patient transport X-ray/CT [Level 4]@Admission or O.R. preparation [level 5]@Triage and Initial RN Assessment only [level 1]@Blood-peripheral venous [level 3]@Oral meds [level 3]@Patient transport

 

 

to display in a separate table as:

 

Capture.PNG

Reeza
Super User
You need to provide sample data then and perhaps someone will help. An image means someone has to type out the text.
gbond21
Obsidian | Level 7

Sorry about that, new to this!

 

 

The sample data and sample desired output are attached to this message in the excel file on seperate sheets.