Desktop productivity for business analysts and programmers

ERROR: The function LOCATEC is unknown, or cannot be accessed.

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

ERROR: The function LOCATEC is unknown, or cannot be accessed.

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


Accepted Solutions
Solution
‎04-10-2017 09:33 AM
Respected Advisor
Posts: 4,131

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

@Pank81

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.

View solution in original post


All Replies
Super User
Posts: 5,360

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

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?

Occasional Contributor
Posts: 5

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

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.

Super Contributor
Posts: 252

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

SCL can do it. A datastep, with dataset functions, cannot.

Occasional Contributor
Posts: 5

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

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.

 

Super User
Posts: 19,063

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

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?

Occasional Contributor
Posts: 5

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

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

Solution
‎04-10-2017 09:33 AM
Respected Advisor
Posts: 4,131

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

@Pank81

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.

Occasional Contributor
Posts: 5

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

@Patrick: Thank you. Excatly what Dr odered...

 

Super User
Posts: 19,063

Re: ERROR: The function LOCATEC is unknown, or cannot be accessed.

You can use the File functions, but you're better off querying the SASHELP.VCOLUMN table IMO.

☑ This topic is solved.

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

Discussion stats
  • 9 replies
  • 383 views
  • 2 likes
  • 5 in conversation