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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

@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

9 REPLIES 9
Astounding
PROC Star

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?

Pank81
Calcite | Level 5

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.

LaurieF
Barite | Level 11

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

Pank81
Calcite | Level 5

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.

 

Reeza
Super User

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?

Pank81
Calcite | Level 5

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

Patrick
Opal | Level 21

@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.

Pank81
Calcite | Level 5

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

 

Reeza
Super User

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 9 replies
  • 4949 views
  • 2 likes
  • 5 in conversation