Hi everyone
I need help with 2 issues
1. I have a file containing thousands of enteries that look like this:
PatientFirstName;PatientLastName;PatientDateOfBirth;PatientID;HomeDoctorSalutation;HomeDoctorFirstName;HomeDoctorLastName;ExamType;ExamDate;ExaminerSalutation;ExaminerFirstName;ExaminerLastName; Comment 3;Image Comment 4;_x000D_
"John";"Doe";"01/01/99";"9999999";"MS";"Alex";"Josef";"surgery";"01/01/17";"MR";"John";"Watson";"Mr";"Sherlock";"Holmes";"GX";"11111";"";"";"";"";"";"";
I need to extract the parts I marked in red, basically, the first 4 entries between citation marks, and the 9th one. They are always in that order and always between citations
Then Another file with entries as follows:
X:\1111111_5748392_222222222_DDDDD.PDF
I also need the entry I marked in red, basically the one between "\" and "_"
I know this is doable with regular expression, but it would probably take me a couples of days to figure out a solution, so reaching out to the community for some help please...
Kind regards
AM
Hi,
you can achieve what you want with this piece of code:
/*
I need to extract the parts I marked in red, basically, the first 4 entries between citation marks
and the 9th one. They are always in that order and always between citations
*/
proc import datafile="X:\YourFile.txt"
out=test1
dbms=csv
replace;
getnames=yes;
delimiter=';';
;
run;
data test2;
set test1;
keep PatientFirstName PatientLastName PatientDateOfBirth PatientID ExamDate;
run;
/*
I also need the entry I marked in red, basically the one between "\" and "_"
*/
filename files pipe 'dir "X:\*.pdf" /b/a-d ' lrecl=5000;
data a;
infile files truncover;
input files $char1000.;
files=scan(files,1,'_');
run;
- Cheers -
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.