Help using Base SAS procedures

Pulling Specific Character Variables

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Pulling Specific Character Variables

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.


Accepted Solutions
Solution
‎12-02-2013 04:23 PM
Contributor
Posts: 57

Re: Pulling Specific Character Variables

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


All Replies
Solution
‎12-02-2013 04:23 PM
Contributor
Posts: 57

Re: Pulling Specific Character Variables

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;

Occasional Contributor
Posts: 6

Re: Pulling Specific Character Variables

Thank you. Works like it should

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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