Something like this might be able to read the file properly to begin with.
I may have included more checks for existing values but once you have one set of inconsistent values such as Street2 and the House number everything becomes questionable in my book.
If you don't want the house number the drop it. You may need to set the length of some variables longer.
data work.want;
infile datalines dlm=',/' truncover;
input @"Street 1: " Street1 :$15. @;
if findw(_infile_,"HSE No:")> 0 then input @"HSE No: " Housenum :$15. @;
if findw(_infile_,"Street 2:")> 0 then input @"Street 2: " Street2 :$15. @;
if findw(_infile_,"City:")> 0 then input @"City: " City :$15. @;
if findw(_infile_,"State:")> 0 then input @"State: " State :$15. @;
if findw(_infile_,"Zip:")> 0 then input @"Zip: " Zip :$15. @;
if findw(_infile_,"Country:")> 0 then input @"Country:" Country :$15. @;
input;
;
datalines;
Street 1: ABC PL, HSE No: 100, Street 2: ATTN xxxx / City: Loredo, State: TX, Zip: 77702-2600,/ Country: US
Street 1: Cochte Rd, HSE No: 770,/City: FRAMI, State: MI, Zip: 01221-4666,/Country: US
Street 1: S 6th St, Street 2: Mail Stop ,/City: Manglore, State: MN, Zip: 66402-3601,/Country: US
Street 1: THOMAS PL,/City: EVERMAN, State: TX, Zip: 76140-4610,/Country: US
;
Please post code and data into a code box opened using the forum's {I} icon. The forum main message windows will reformat text to some extent and what we see may not be what you actually have.
Plus extra line feeds aren't helpful.
... View more