Good Morning,
So I would like to pull variables that contain a specific character string in the beginning, followed by any combination afterword.
For examples, I want to pull zip codes (character) but only want the specific zip codes "97252" and anything else that comes after those 5 specific characters like the dash and state code.
Please help.
Thank you.
There are several ways to do this, but how about a sql statement with the like function?:
proc sql;
create table work.output as
select * from
work.input a
where
a.zipcode like '97252%';
quit;
You could also do this in a data step with =: operator:
data work.output;
set work.input;
if zipcode=:'97272' then output;
run;
There are several ways to do this, but how about a sql statement with the like function?:
proc sql;
create table work.output as
select * from
work.input a
where
a.zipcode like '97252%';
quit;
You could also do this in a data step with =: operator:
data work.output;
set work.input;
if zipcode=:'97272' then output;
run;
Thank you. Works like it should
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.