BookmarkSubscribeRSS Feed
Cooksam13
Fluorite | Level 6

I am having trouble understanding PRx.

I have data where most of the information is written in the "notes section" in files in different ways. 

 

I am locating, when patients were tested with for Hep B, and the result of the test,

the text string can be something like this:

"Chronic viral hepatitis B, asymptomatic. Positive HBS-Ag test is detected for are first time."

"hep B infection, check for symptoms, hep B positive check if symtomatic"

"HBS-Ag was negative (6/6/2020)"

"HEPATITIS B AG (11/14/08) NON REACTIVE"

"HBsAg analysis done on 30-JUN-11:N"

 

I have only located where Hep B is mentioned with this type of SAS code:

 

data program.new;
set sheet.new;
if index(upcase(CongestiveHeartFailure), 'HEP C') then hepcheck = 0;
Else if index(upcase(CongestiveHeartFailure), 'HEPATITIS C') then hepcheck = 0;
else if index(upcase(CongestiveHeartFailure), 'HEP') then Hepcheck = 1 ;
else if index(upcase(CongestiveHeartFailure), 'HBSAG') then HEpCheck = 1;
else if index(upcase(CongestiveHeartFailure), 'HBV') then HEpCheck = 1;
Else if index(upcase(MedicalHistoryRemarks), 'HEP C') then hepcheck =0;
Else if index(upcase(MedicalHistoryRemarks), 'HEPATITIS c') then hepcheck =1;
else if index(upcase(MedicalHistoryRemarks), 'HEP') then Hepcheck = 1;
else if index(upcase(MedicalHistoryRemarks), 'HBSAG') then HepCheck = 1;
else if index(upcase(MedicalHistoryRemarks), 'HBV') then HEpCheck = 1;

else Hepcheck = 0;

if hepcheck = 0 then delete;
keep hepcheck  MedicalHistoryRemarks CongestiveHeartFailure ;
run;

 

but I am trying to extract and quantify the information that I mentioned above into "checked for Hep B" "test result" "date" "follow up" and to coincide with the patient ID number.

 

I am having trouble with Prx and I was hoping someone could help.

thank you!

2 REPLIES 2
Patrick
Opal | Level 21

With such freeform text strings it's going to be very painful to identify and extract the information you're after. You will have to go through n-iterations amending/extending code and then check the quality of the result ....and amend further based on the result. Not sure how someone really can help you with this without having the full set of data.

 

IF your data is not too big then at one point switching to just manually go through the data and populate the fields you need could become more efficient.

andreas_lds
Jade | Level 19

Can you post an excerpt of the data you have in usable form (data step using datalines, no attachments) so that we have a common starting point?

Posting the expected results seems a good idea, too, so that contributes could verify that they are on the right track.

 

If you need to check multiple variables, defining an array could reduce the number of lines you have to write, calling upcase before the comparisons start, reduced to code further. In the code shown, i hardly see a way to simplify then with expressions.

 

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
  • 2 replies
  • 1589 views
  • 0 likes
  • 3 in conversation