DATA Step, Macro, Functions and more

Error when %including more scoring codes

Reply
Occasional Contributor
Posts: 6

Error when %including more scoring codes

Hi,

 

I have more models (HPLogistic/HPgenselect) and use CODE FILE to score data.

 

When reading this file using %include into a datastep like this:

 

DATA want;
SET have;
%include '\\sasmat\FirstHPgenSelect.sas'
%include '\\sasmat\SecondHPgenSelect.sas'
%include '\\sasmat\ThirdHPgenSelect.sas'
RUN;

following error occurres:

 

+_SKIP_000:
           _________
           305
ERROR 305-185: Label has already been used.

 

... It reads only the first %include and gives the error for all the others. It seems like the code wants to navigate to a specific location in the generated scoring code which has the same name in all these files and Sas can't handle it.

 

Any idea how to overcome this problem is highly appriciated.

 

Thanks Smiley Wink

 

___

*SAS EG version 7.15 HF3 (7.100.5.6132) (64-bit)

Super User
Posts: 9,874

Re: Error when %including more scoring codes

Posted in reply to JamesBlack

This looks like the code in the include files uses goto and a specific label. Within one data step, a label can appear only once. Change the goto statements and the labels in the includes so no label is used repeatedly.

It might also be that the whole scoring code is structured in a way that only one of them can be used at any time, so you might get other issues.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 6

Re: Error when %including more scoring codes

Posted in reply to KurtBremser
Thank you, I noticed this. I don't know how to do that without having to edit all included files separatly...

The option to be able to use only one scoring code doesn't look good to me, since I need to score quite big dataset with bunch of models...
Super User
Super User
Posts: 9,402

Re: Error when %including more scoring codes

[ Edited ]
Posted in reply to JamesBlack

First off, do not put %include statements in a datastep - they are not datastep components.  Second, an include statement should be finished with a semicolon.  Third, dont code in uppercase.

%include '\\sasmat\FirstHPgenSelect.sas';
%include '\\sasmat\SecondHPgenSelect.sas';
%include '\\sasmat\ThirdHPgenSelect.sas';

data want;
  set have;
run;

 

Would be more appropriate, although I suspect you have some general SAS code in those files you would want to include in your program, if so make them macros and then call the macro in the datastep, much cleaner, and you could then put them on the sasautos and not include at all.

Occasional Contributor
Posts: 6

Re: Error when %including more scoring codes

[ Edited ]

To your First, it is proper technique to score data using %include in data step, see "The CODE statement". I'm aware of semicolons, I just forgot them in this sample code... I would be getting different error, if they were not in my script.
I have not noticed that SAS would be case sensitive...

 

Calling this file from a macro desn't make any difference since it doesn't change anything inside the file which causes the error.

Super User
Super User
Posts: 9,402

Re: Error when %including more scoring codes

Posted in reply to JamesBlack

I always advise to put setup things at the top, such as include files, macro variables, options, so it is clear where things are defined.  In this case it seems to be different, so can't speak there.  What I was getting as was to put the code within the included files a a macro and then call that, thus utilising sasautos, however again, in this instance this appears to go against the grain.

SAS itself is not case sensitive, but my eyes are.  Code is far easier to read and debug when not written in uppercase.

Valued Guide
Posts: 516

Re: Error when %including more scoring codes

Posted in reply to JamesBlack

Renaming the label and fixing all goto statements using it is the easy way to solve this. Not using labels and goto in a data step would be my first choice.

Occasional Contributor
Posts: 6

Re: Error when %including more scoring codes

Posted in reply to andreas_lds

Mine too, but I don't know how to do that in a simple way in one piece of code. Editing multiple prefabricated SAS codes which suppose to save my time, seems ineffective to me...

Super User
Super User
Posts: 7,932

Re: Error when %including more scoring codes

Posted in reply to JamesBlack

Just guessing here since you didn't include full code (or log) but it looks like your separate %INCLUDE blocks are all using the same LABEL statement. 

_SKIP_000:

So you cannot use them together in the same data step.

 

Either code them to use unique labels.

Or run them as separate data steps.

Or find another way to do this that does not need labels.

Ask a Question
Discussion stats
  • 8 replies
  • 76 views
  • 2 likes
  • 5 in conversation