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

Hi ,

    I need to filter out data in the "ZIP" column of a data set. It has few values which start with a character variable (A-Z). How can I filter them in a dataset of 1000000 rows. Column "ZIP" is a categorical variable.

    I did try this approach but there seems something to be wrong :

proc sql;

delete * from dataset where zip = '^[A-Z]';

quit;

The log says no rows are selected. Please advice !

Thanks ,

Minal

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
data _null_;
  
input zip $;
   notdigit = verify(first(zip),'0123456789');
   put _all_;
  
cards;
10123
u9900
90210
;;;;
   run;

15         data _null_;
16            input zip $;
17            notdigit = verify(first(zip),'0123456789');
18            put _all_;
19            cards;

zip=
10123 notdigit=0 _ERROR_=0 _N_=1
zip=u9900 notdigit=
1 _ERROR_=0 _N_=2
zip=
90210 notdigit=0 _ERROR_=0 _N_=3

View solution in original post

5 REPLIES 5
UrvishShah
Fluorite | Level 6

proc sql;

  select *

  from have

  where anayalpha(ZIP);

quit;


MinalMMurkhande
Calcite | Level 5

Thanks for the reply. But on running the code I get the following error :

23         proc sql;

24           select *

25           from project.a1

26           where anayalpha(ZIP);

ERROR: Function ANAYALPHA could not be located.

But anyways I tried running this :

proc sql;

    select * from project.a1 where prxmatch('/^[A-Z]/', zip);

quit;

and it worked.

Thanks,

Minal

RW9
Diamond | Level 26 RW9
Diamond | Level 26

Typo in word anyalpha:

where anyalpha(ZIP);

pradeepalankar
Obsidian | Level 7

it should be

if anyalpha(zip)=1;

1 is for if zip starts with character value.

data_null__
Jade | Level 19
data _null_;
  
input zip $;
   notdigit = verify(first(zip),'0123456789');
   put _all_;
  
cards;
10123
u9900
90210
;;;;
   run;

15         data _null_;
16            input zip $;
17            notdigit = verify(first(zip),'0123456789');
18            put _all_;
19            cards;

zip=
10123 notdigit=0 _ERROR_=0 _N_=1
zip=u9900 notdigit=
1 _ERROR_=0 _N_=2
zip=
90210 notdigit=0 _ERROR_=0 _N_=3

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1186 views
  • 3 likes
  • 5 in conversation