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!

Basic SAS question

Status
Not open for further replies.

sarav1981

Programmer
Jul 14, 2005
29
US
Hi all,

I have a piece of SAS code that I have trouble deciphering what it does. The code snippet is given below:

data files;
set file;
if fileref =: '#LN' or fileref =: 'SAS' then delete;
run;

My query is

1. What does '=:' do in the above code?
2. How is it different from the basic 'equal to' operator?

It would be grateful if I can get some detailed explanations on the queries.

Thanks,
Sarav
 
Sarav,
This operator is not the 'equal' oper. It is the compare operator. What your code says is the following:
if the var fileref's value has the '#LN' in its first three positions return true, or , if the var fileref has the letters "SAS" in the first 3 positions return true.
Klaz
 
Klaz2002,

Thanks a lot for your explanation. I was having a bit of trouble deciphering what it meant in my code and the SAS documentation wudnt help me either.

I have another question to ask. If I need to equate var fileref with '#LN' or 'SAS' which occur in the middle of the var value, do I have only the SUBSTR fn to get to it? Also, Is it possible for me to use something like in SQL. An example is:

proc sql;
create table files as
(select *
from file
where (fileref like '%#LN%' or fileref like '%SAS%');
);
run;

Thanks for your response and looking forward to your answer.

Sarav
 
Sarav,
Yes there is a way you can select by that criteria. Use the index() function.
ex.
Code:
data files;
  set file;
  if index(fileref,'#LN') gt 0 or
     index(fileref,'SAS') gt 0 then delete;
run;

What this does is return the position of the first occurence in the string. If the search string is not found this function returns a zero.

I Hope that this helps you.
Klaz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top