BookmarkSubscribeRSS Feed
David_Billa
Rhodochrosite | Level 12

I would like to how to change the value of automatic macro variable &syscc. I tried the code below, but it's not working. Any help?  Also I want to know some examples where we get this error in real life. I knew that error code 1012 means 'General error condition' what does mean is my question.

 

%let syscc=1012;

data _null_;

if &syscc.=1012 then

call symput(syscc,0);

run;

 

Error:

NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
      29:36   29:42   
ERROR: Symbolic variable name            . must begin with a letter or underscore.
NOTE: Invalid argument to function SYMPUT('           .','           0') at line 29 column 29.
SYSCC=. _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.

14 REPLIES 14
Kurt_Bremser
Super User

call symput() expects character arguments; since your data step does not define data step variable syscc, it is automatically created as numeric with a missing value, and that does not work.

You need this:

%let syscc=1012;
data _null_;
if &syscc. = 1012 then call symput("syscc","0");
run;

so you have a character literal instead of a variable name.

David_Billa
Rhodochrosite | Level 12
On what scenarios we will see &syscc resolves to 1012?
Kurt_Bremser
Super User

You can find a list of SAS error codes in the documentation for the SYSERR Automatic Macro Variable. In short, 1012 is a very often appearing code.

In my programs, I only check for &syscc ne 0, as my codes are written in a way that they stay absolutely clean on a successful run. No ERRORs, no WARNINGs.

David_Billa
Rhodochrosite | Level 12
OK, but in my program I don't know where it is getting resolved to 1012.
It's a very big program which includes multiple data steps and when I see
the value of syscc it is resolved to 1012 and there is no error in the log
except the warning.

I have used syscc only at the end of the program, so I'm not certain where
it is getting to resolved to 1012.

It's a painful task if I was asked to write syscc at the end of each step.
How to identify which step has syscc that resolves to 1012?
Quentin
Super User

@David_Billa wrote in part:

It's a painful task if I was asked to write syscc at the end of each step.
How to identify which step has syscc that resolves to 1012?

I suggest searching the log for errors, warnings, or bad notes.

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
David_Billa
Rhodochrosite | Level 12
There is no error in the log and of course there are few warnings which is
OK for me. So those warnings might have contributed to syscc to resolve
1012?
Kurt_Bremser
Super User

No program that deserves to be called a program throws a WARNING. NOT A SINGLE ONE.

Unless something untoward happens, then the developer checks for the reason and either provides a fix in the program or sends the damaged input data back to the source, with a request to correct it.

 

See Maxims 24 and 25.

 

Return codes not zero have to be used to detect unwanted, abnormal situations, aside from that they must NOT be tolerated. How could you reliably detect a successful run otherwise?

FreelanceReinh
Jade | Level 19

@David_Billa wrote:
It's a painful task if I was asked to write syscc at the end of each step.
How to identify which step has syscc that resolves to 1012?

You don't need to write it at the end of each step if you use the bisection method: If your program consists of, say, up to 256 (in general: 2**n) steps and global statements, it will suffice to retrieve the value of SYSCC up to 8 (in general: n) times. First, %put &syscc; would be placed after the first half of the steps/global statements, then moved after the first or third quarter depending on whether the first SYSCC value was 1012 or 0, and so on. After each check only about half of the remaining steps/global statements need to be investigated further.

 

Once you've identified the step or statement which causes &SYSCC=1012 without an error message, please post it here.

David_Billa
Rhodochrosite | Level 12
I don't want to count the number of steps in my program as I'm sure there
are more than 256.So can I randomly place syscc for every few steps?
FreelanceReinh
Jade | Level 19

@David_Billa wrote:
I don't want to count the number of steps in my program as I'm sure there
are more than 256.

It's not necessary to determine exact numbers of steps or global statements as long as you keep track of the previous location of the %put &=syscc; statement whenever you move it to a new position. You can also use the line numbers of your program instead of step numbers to find a reasonable location for the statement.

 


@David_Billa wrote:
So can I randomly place syscc for every few steps?

Even a single %put &=syscc; statement per run would be sufficient. The trick is to move it systematically depending on the previous result so that the amount of code potentially containing the faulty line is (approximately) cut in half in every recursion of the process.

 

Obviously, you can start with submitting only the upper half of the program. If &SYSCC is still 0 at this point (i.e., the upper half is error-free as far as SYSCC is concerned), continue with the third quarter of the program (i.e., the "upper half of the bottom half"). Otherwise you know that the culprit must be somewhere in the upper half and you can restrict the next run to the first quarter of the program. Either way, after the second (partial) run you know the quarter of the program where &SYSCC becomes 1012 first. Similarly, after the third (partial) run you know the eighth of the program where this happens, and so on.

Kurt_Bremser
Super User

How did you scan for the words ERROR and WARNING?

Check for syscc ne 0 right at the start of your program, it might be that you "inherit" the SYSCC code from the autoexec. If that is the case, have the SAS administrator fix it, or do

%let syscc = 0;

as the very first statement in your code.

David_Billa
Rhodochrosite | Level 12
Could you please tell me how to check for syscc ne 0 at the start of the
program?

My program already had syscc=0 as a first line.
DavePrinsloo
Pyrite | Level 9
Spoiler
 

I suggest that you add a line of code 
options dsoptions=note2err;

at the beginning of your long program. That will better highlight problems that you may have overlooked.  Then fix your code so that these new errors are avoided.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 14 replies
  • 3068 views
  • 4 likes
  • 5 in conversation