BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nehemiah
Calcite | Level 5

Here is the example format of hl7 message

 

MSH|^~\&||||1171400021|201811151034||ORU^R01|002186496759697690|P|2.3
PID||LLQBK010450|E1404514631^^^Y^EPI||98818^999 AAA||20000505|M|||^^^^^||||||||999999999|
PV1|1||||||^^^^^^^||||||||U||||||||||||||||||||||||
ORC|RE||||P
OBR|1|LLQBK0484340||LAB1725^CBC WITH DIFFERENTIAL^^|||201811141725||||||SCR|201811150930||^QPS^Bio-Kinetic^||||||201811151033|||F|||||||||||||||
NTE|1||CLINICAL INFO: SCR
OBX|1||1202450^WBC^^|| 6.2|K/uL|4.5-12.5||||F||||11|||
OBX|2||1202305^RBC^^|| 4.09|M/uL|4.60-6.20|L|||F||||11|||
OBX|3||1202108^HEMOGLOBIN^^|| 12.6|g/dL|14.0-18.0|L|||F||||11|||
OBX|4||1202105^HEMATOCRIT^^|| 37.8|%|41.0-53.0|L|||F||||11|||
OBX|5||1202197^MCV^^|| 92.4|fL|84.0-103.0||||F||||11|||
OBX|6||1202195^MCH^^|| 30.8|pg|27.0-34.0||||F||||11|||
OBX|7||1202196^MCHC^^|| 33.3|g/dL|30.0-35.0||||F||||11|||
OBX|8||1202306^RDW^^|| 12.6|%|11.0-14.5||||F||||11|||
OBX|9||1204184^RDW-STDEV^^|| 42.4|fL|37.0-54.0||||F||||11|||
OBX|10||1202276^PLATELETS^^|| 195|K/uL|140-440||||F||||11|||
OBX|11||1202550^MPV^^|| 12.1|fL|8.9-12.8||||F||||11|||
OBX|12||1202615^NEUTROPHILS^^|| 52|%|42-75||||F||||11|||
OBX|13||1202616^LYMPHOCYTES^^|| 36|%|24-44||||F||||11|||
OBX|14||1202617^MONOCYTES^^|| 10|%|2-10||||F||||11|||
OBX|15||1202618^EOSINOPHILS^^|| 1|%|0-7||||F||||11|||
OBX|16||1202619^BASOPHILS^^|| 1|%|0-1||||F||||11|||
OBX|17||1205095^IMMATURE GRANULOCYTES^^|| 0|%|0-2||||F||||11|||
OBX|18||1202578^NEUTROPHIL ABSOLUTE^^|| 3.22|K/uL|2.00-8.00||||F||||11|||
OBX|19||1202579^LYMPHOCYTE ABSOLUTE^^|| 2.20|K/uL|1.20-4.00||||F||||11|||
OBX|20||1202580^MONOCYTE ABSOLUTE^^|| 0.61|K/uL|0.10-0.60|H|||F||||11|||
OBX|21||1202581^EOSINOPHIL ABSOLUTE^^|| 0.06|K/uL|0.00-0.70||||F||||11|||
OBX|22||1202582^BASOPHILS ABSOLUTE^^|| 0.04|K/uL|0.00-0.20||||F||||11|||
OBX|23||1205096^IMMATURE GRANULOCYTES ABSOLUTE^^|| 0.02|K/uL|0.00-0.10||||F||||11|||
NTE|1||CLINICAL INFO: SCR
FTS|1|End Of File

 

If there any procedure to import hl7/.obx file in SAS

 

Please help me out!!!!

Thanks in advance!!!

Nehemiah.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ScottBass
Rhodochrosite | Level 12

Please help us out!!!!

What is your desired output?

 

This may get you started.  I don't see anything in your file that tells me the column names, but you could rename them in a post-processing step.

 

* create a file (for testing/development) ;
filename obx temp;
data _null_;
   file obx;
   input;
   put _infile_;
   datalines4;
MSH|^~\&||||1171400021|201811151034||ORU^R01|002186496759697690|P|2.3
PID||LLQBK010450|E1404514631^^^Y^EPI||98818^999 AAA||20000505|M|||^^^^^||||||||999999999|
PV1|1||||||^^^^^^^||||||||U||||||||||||||||||||||||
ORC|RE||||P
OBR|1|LLQBK0484340||LAB1725^CBC WITH DIFFERENTIAL^^|||201811141725||||||SCR|201811150930||^QPS^Bio-Kinetic^||||||201811151033|||F|||||||||||||||
NTE|1||CLINICAL INFO: SCR
OBX|1||1202450^WBC^^|| 6.2|K/uL|4.5-12.5||||F||||11|||
OBX|2||1202305^RBC^^|| 4.09|M/uL|4.60-6.20|L|||F||||11|||
OBX|3||1202108^HEMOGLOBIN^^|| 12.6|g/dL|14.0-18.0|L|||F||||11|||
OBX|4||1202105^HEMATOCRIT^^|| 37.8|%|41.0-53.0|L|||F||||11|||
OBX|5||1202197^MCV^^|| 92.4|fL|84.0-103.0||||F||||11|||
OBX|6||1202195^MCH^^|| 30.8|pg|27.0-34.0||||F||||11|||
OBX|7||1202196^MCHC^^|| 33.3|g/dL|30.0-35.0||||F||||11|||
OBX|8||1202306^RDW^^|| 12.6|%|11.0-14.5||||F||||11|||
OBX|9||1204184^RDW-STDEV^^|| 42.4|fL|37.0-54.0||||F||||11|||
OBX|10||1202276^PLATELETS^^|| 195|K/uL|140-440||||F||||11|||
OBX|11||1202550^MPV^^|| 12.1|fL|8.9-12.8||||F||||11|||
OBX|12||1202615^NEUTROPHILS^^|| 52|%|42-75||||F||||11|||
OBX|13||1202616^LYMPHOCYTES^^|| 36|%|24-44||||F||||11|||
OBX|14||1202617^MONOCYTES^^|| 10|%|2-10||||F||||11|||
OBX|15||1202618^EOSINOPHILS^^|| 1|%|0-7||||F||||11|||
OBX|16||1202619^BASOPHILS^^|| 1|%|0-1||||F||||11|||
OBX|17||1205095^IMMATURE GRANULOCYTES^^|| 0|%|0-2||||F||||11|||
OBX|18||1202578^NEUTROPHIL ABSOLUTE^^|| 3.22|K/uL|2.00-8.00||||F||||11|||
OBX|19||1202579^LYMPHOCYTE ABSOLUTE^^|| 2.20|K/uL|1.20-4.00||||F||||11|||
OBX|20||1202580^MONOCYTE ABSOLUTE^^|| 0.61|K/uL|0.10-0.60|H|||F||||11|||
OBX|21||1202581^EOSINOPHIL ABSOLUTE^^|| 0.06|K/uL|0.00-0.70||||F||||11|||
OBX|22||1202582^BASOPHILS ABSOLUTE^^|| 0.04|K/uL|0.00-0.20||||F||||11|||
OBX|23||1205096^IMMATURE GRANULOCYTES ABSOLUTE^^|| 0.02|K/uL|0.00-0.10||||F||||11|||
NTE|1||CLINICAL INFO: SCR
FTS|1|End Of File
;;;;
run;

* get the max column count of non-missing columns;
data _null_;
   retain column_count;
   count=0;
   infile obx end=eof;
   input;
   if _infile_ =: "OBX" then
   do i=1 to countc(_infile_,"|^")+1;
      if not missing(scan(_infile_,i,"|^")) then count+1;
      column_count=max(column_count,count);
   end;
   if eof then call symputx("column_count",column_count);
run;
%put &=column_count;

data foo;
   infile obx lrecl=32767;
   length var1-var&column_count $100;
   array vars{*} var:;
   input;
   if _infile_ =: "OBX";
   do i=1 to dim(vars);
      vars{i}=scan(_infile_,i,"|^");
   end;
   drop i;
run;

 

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.

View solution in original post

3 REPLIES 3
ScottBass
Rhodochrosite | Level 12

Please help us out!!!!

What is your desired output?

 

This may get you started.  I don't see anything in your file that tells me the column names, but you could rename them in a post-processing step.

 

* create a file (for testing/development) ;
filename obx temp;
data _null_;
   file obx;
   input;
   put _infile_;
   datalines4;
MSH|^~\&||||1171400021|201811151034||ORU^R01|002186496759697690|P|2.3
PID||LLQBK010450|E1404514631^^^Y^EPI||98818^999 AAA||20000505|M|||^^^^^||||||||999999999|
PV1|1||||||^^^^^^^||||||||U||||||||||||||||||||||||
ORC|RE||||P
OBR|1|LLQBK0484340||LAB1725^CBC WITH DIFFERENTIAL^^|||201811141725||||||SCR|201811150930||^QPS^Bio-Kinetic^||||||201811151033|||F|||||||||||||||
NTE|1||CLINICAL INFO: SCR
OBX|1||1202450^WBC^^|| 6.2|K/uL|4.5-12.5||||F||||11|||
OBX|2||1202305^RBC^^|| 4.09|M/uL|4.60-6.20|L|||F||||11|||
OBX|3||1202108^HEMOGLOBIN^^|| 12.6|g/dL|14.0-18.0|L|||F||||11|||
OBX|4||1202105^HEMATOCRIT^^|| 37.8|%|41.0-53.0|L|||F||||11|||
OBX|5||1202197^MCV^^|| 92.4|fL|84.0-103.0||||F||||11|||
OBX|6||1202195^MCH^^|| 30.8|pg|27.0-34.0||||F||||11|||
OBX|7||1202196^MCHC^^|| 33.3|g/dL|30.0-35.0||||F||||11|||
OBX|8||1202306^RDW^^|| 12.6|%|11.0-14.5||||F||||11|||
OBX|9||1204184^RDW-STDEV^^|| 42.4|fL|37.0-54.0||||F||||11|||
OBX|10||1202276^PLATELETS^^|| 195|K/uL|140-440||||F||||11|||
OBX|11||1202550^MPV^^|| 12.1|fL|8.9-12.8||||F||||11|||
OBX|12||1202615^NEUTROPHILS^^|| 52|%|42-75||||F||||11|||
OBX|13||1202616^LYMPHOCYTES^^|| 36|%|24-44||||F||||11|||
OBX|14||1202617^MONOCYTES^^|| 10|%|2-10||||F||||11|||
OBX|15||1202618^EOSINOPHILS^^|| 1|%|0-7||||F||||11|||
OBX|16||1202619^BASOPHILS^^|| 1|%|0-1||||F||||11|||
OBX|17||1205095^IMMATURE GRANULOCYTES^^|| 0|%|0-2||||F||||11|||
OBX|18||1202578^NEUTROPHIL ABSOLUTE^^|| 3.22|K/uL|2.00-8.00||||F||||11|||
OBX|19||1202579^LYMPHOCYTE ABSOLUTE^^|| 2.20|K/uL|1.20-4.00||||F||||11|||
OBX|20||1202580^MONOCYTE ABSOLUTE^^|| 0.61|K/uL|0.10-0.60|H|||F||||11|||
OBX|21||1202581^EOSINOPHIL ABSOLUTE^^|| 0.06|K/uL|0.00-0.70||||F||||11|||
OBX|22||1202582^BASOPHILS ABSOLUTE^^|| 0.04|K/uL|0.00-0.20||||F||||11|||
OBX|23||1205096^IMMATURE GRANULOCYTES ABSOLUTE^^|| 0.02|K/uL|0.00-0.10||||F||||11|||
NTE|1||CLINICAL INFO: SCR
FTS|1|End Of File
;;;;
run;

* get the max column count of non-missing columns;
data _null_;
   retain column_count;
   count=0;
   infile obx end=eof;
   input;
   if _infile_ =: "OBX" then
   do i=1 to countc(_infile_,"|^")+1;
      if not missing(scan(_infile_,i,"|^")) then count+1;
      column_count=max(column_count,count);
   end;
   if eof then call symputx("column_count",column_count);
run;
%put &=column_count;

data foo;
   infile obx lrecl=32767;
   length var1-var&column_count $100;
   array vars{*} var:;
   input;
   if _infile_ =: "OBX";
   do i=1 to dim(vars);
      vars{i}=scan(_infile_,i,"|^");
   end;
   drop i;
run;

 

 


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Nehemiah
Calcite | Level 5

Hi Scott 

 

Thank you for your solution..the given program code is really helped us a lot.

 

Regards

 

B.Nehemiah 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Its a pipe delimited file, therefore use a datastep with infile and specify dlm="|".  As for format then look at the HL7 website for information:

https://blog.interfaceware.com/understanding-hl7-messages/

https://en.m.wikipedia.org/wiki/Health_Level_7

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 997 views
  • 0 likes
  • 3 in conversation