Hello,
I have a variable with street and number in one string. I would like to split them into two variables:
data example;
input street_number $30.;
datalines;
Limburger Str. 15a
Genter Str. 1
Schanzenstrasse 12 b
Hollunder Weg 92
;
run;
I am looking for a function which can split - if the first character is a number
My output should look like:
Street Number
Limburger Str. 15a
Genter Str. 1
Schanzenstrasse 12 b
Hollunder Weg 92
I was thinking about substr() and scan() but I couldn't found a good advise on google.
Best Regards
Silke
data example;
input street_number & :$50.;
datalines;
Limburger Str. 15a
Genter Str. 1
Schanzenstrasse 12 b
Hollunder Weg 92
;
run;
data solution;
set example;
street=substr(street_number,1,anydigit(street_number)-1);
Number=substr(street_number,anydigit(street_number),length(street_number));
run;
Regards,
Naveen Srinivasan
L&T Infotech
have you tried using ANYDIGIT function?
PRX fucntions? http://www2.sas.com/proceedings/forum2007/223-2007.pdf
Sir, Forgive me, I trust and totally agree PRX will work seamlessly, but I am not even anywhere close or to your level of expertise, so I still have to learn PRX from the very begining. I really appreciate sharing the doc, does the really cover from the very basic to considerable advance level of PRX functions and should i have to learn perl scripting before learning to use PRX functions, If so, that sounds very daunting.:smileyconfused:
BTW, I have taken a lot of your help in the past from other posts, although never had a chance to thank personally. Cheers!
Naveen for PRX just take some sample as posted and do a trial for an easy problem when that one succeeds and understood go for the more difficult ones.
You do not need to learn the PERL just the PRX part. Samples are more easy to follow than the docs.
SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition (reference PRX ,metadatachars)
SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition (PRXPARSE doc) the one that does the PRX compilation. Preferable needed only once in a datastep
data example;
input street_number & :$50.;
datalines;
Limburger Str. 15a
Genter Str. 1
Schanzenstrasse 12 b
Hollunder Weg 92
;
run;
data solution;
set example;
street=substr(street_number,1,anydigit(street_number)-1);
Number=substr(street_number,anydigit(street_number),length(street_number));
run;
Regards,
Naveen Srinivasan
L&T Infotech
Thank you!!!
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.