I am trying to read the email_list file and output only email addresses separated by semi-column. But my code goes into a loop.
Can anybody help me in this??
email_file.txt has following records:
Doe, John <email@example.com>;Smith, Jeff <firstname.lastname@example.org>; lever, dave <email@example.com>
Below is my code:
length text $32767;
infile 'c\email_file.txt' lrecl=32767 dsd dlm='09'x truncover;
input text $;
length tx3 $500;
do until (length(cats(tx1))=0);
space_position = INDEX(tx1, '<');
slash_position = INDEX(tx1, '>');
space_to_slash = slash_position - space_position;
tx2 = substr(tx1, space_position+1, space_to_slash-1);
Looks like you want to take the parts inside of the <>. This code will do that and also take values that only have the email address without the name and so do not have any <>s.
You can scan the original list using ';' as the delimiter and then within each sub-string look for the values between the <> using scan function again, this time using both < and > as the delimiters.
data want; set test ; length want $32767 ; do i=1 to countw(text,';'); want = catx(';',want,scan(scan(text,i,';'),-1,'<>')); end; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.