Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Wildcards 1

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hello

I am very new to SAS (9.1) and this is probably a really easy question but I'm gonna ask it anyway:

I have a group of codes I am looking for in an "infile" statement. Some of specific and others I want any that begins with it to show up.

For instance, the code in question is residence code. The format is 0000232, 0001804 etc. I want to indicate some specifically and then any that starts with 00002 or 00007.

It doesn't appear that the following is working:
If rescode in ("0001804","0003301","00007*","00002*") then output mylib.dad200405res;

What am I doing wrong? Thanks.

Shelby
 
Hi Robbie

Thanks for replying but I'm not sure that answered my question because that example wanted specific fields and I want where between 0000700 to 000799. In Access or any other database I would say "like "0007*" so what do I do in SAS?

Can I use the IN operator for those that are specifics and then "OR LIKE" for these ones?

Thanks.
 
Can you read those values in as numeric instead of characters? If so the filtering is more straight forward. Just a thought.


dje
 
Try this:-
Code:
   If rescode in:("0001804","0003301","00007","00002")...

the : after the in basically translates as "starts with". You can also use this with the = sign.

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Hi Chris

Thanks very much for your reply. I finally consulted with SAS on this and of course they gave me the same answer you did though they didn't tell me that it is the same as "start with" which is great information (I find I learn better when relating to stuff I already know!).

So thanks again.

Shelby
 
No worries. If I hadn't been on holiday for the last 2 weeks you might have got the answer sooner :)

Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top