BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
pbravo
Calcite | Level 5

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.

1 ACCEPTED SOLUTION

Accepted Solutions
statistician13
Quartz | Level 8

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;

View solution in original post

2 REPLIES 2
statistician13
Quartz | Level 8

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;

pbravo
Calcite | Level 5

Thank you. Works like it should

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 718 views
  • 0 likes
  • 2 in conversation