Friends,
I am trying to run following code but keep getting ERROR message mentioned in subject line. Not sure what's wrong I am doing.
data _null_;
team='Cleveland';
tabelid = open('sashelp.baseball');
rc=locatec(tabelid,varnum(tabelid,'Team'),team,'a');
if (rc=0) then
_msg_= 'There is no Team '||team||'.';
else
do;
_msg_='There is Team '||team||'.';
end;
close=close(tabelid);
run;
Operating enviroment:
SAS 9.04.01M3
SAS EG 7.1
Linux platform
Any suggestion will be helpful.
Thank you,
Pankhil
Below code searches all .lst files in folder c:\temp for "Note: No...." and writes a record to dataset found if there is a match.
Is that what you're after?
data found;
length FoundInFile _CurrentFile $80;
infile 'c:\temp\*.lst' filename=_CurrentFile truncover;
input;
if find(_infile_,'NOTE: No unequal values were found. All values compared are exactly equal','i');
FoundInFile=_CurrentFile;
run;
You could easily extend the code by also adding the line number on which a match has been found.
Well, the error message is pretty explicit. SAS doesn't contain a function named LOCATEC. What is it you are trying to accomplish? Perhaps another tool will suffice?
I am trying to read specific character string in SAS datasets. Just want to see if it is present or not. I tried using usual datasets but exploring if SCL can do same or not. Appricieate your reply.
SCL can do it. A datastep, with dataset functions, cannot.
Sorry did not understand. Do you see any wrong with my logic? If so will you able to update code and show me? Thank you for reply.
We can't see what you're responding to if you don't quote the original text, or make it explicit.
What type of functionality are you trying to build here, checking for the presence of a variable or value of a variable in a dataset?
Do you need an interactive component?
Hi Reeza,
Here is what I am trying to accomplish: I want to scan all .lst files present in one folder and look for string "NOTE: No unequal values were found. All values compared are exactly equal." and get the list.
One way I was thinking about doing was importing .lst file and look for above mentioned string. I can do using dataset and function but though about using SCL. So I was trying LOCATEC() to do so.
I hope I explain my dilema. I am sure there will be better and much easier way to do. Please share if you have any input on this.
Regards,
Pankhil
Below code searches all .lst files in folder c:\temp for "Note: No...." and writes a record to dataset found if there is a match.
Is that what you're after?
data found;
length FoundInFile _CurrentFile $80;
infile 'c:\temp\*.lst' filename=_CurrentFile truncover;
input;
if find(_infile_,'NOTE: No unequal values were found. All values compared are exactly equal','i');
FoundInFile=_CurrentFile;
run;
You could easily extend the code by also adding the line number on which a match has been found.
@Patrick: Thank you. Excatly what Dr odered...
You can use the File functions, but you're better off querying the SASHELP.VCOLUMN table IMO.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.