BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi together!

The following behaviour is extremly dangerous when working with large databases:

data x_tab;
set y_tab;
if (foo=1) then ...do something;
/* But foo is not defined in y_tab! */
run;

In our SAS configuration you won't get any warning or error about the missing foo-variable. SAS just creates it, sets it to missing and that's it.
Any possibility to prevent the creation and to provoke an error or a warning at least?

Thank you in advance!

Christof
5 REPLIES 5
Doc_Duke
Rhodochrosite | Level 12
Not that I am aware of. It has had that feature since version 5 (at least).
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Are you sure - did you try the code yourself?

I expect that you should see the SAS LOG message below:

NOTE: Variable foo is uninitialized.

This condition and the associated diagnostic message is SAS working as designed. There have been previous SAS ballot submissions related to this diagnostic and it's note/warning/error degree and also to suppress it, I believe.

Scott Barry
SBBWorks, Inc.
Doc_Duke
Rhodochrosite | Level 12
Scott,

You are right. I have had an occasion with I haven't have the warning, but my CRS is in overdrive today.

You get a note, but not a warning.

data temp;
input a;
cards;
1
run;

DATA; set;
IF foo=1 THEN;
RUN;

NOTE: Variable foo is uninitialized.


Doc
deleted_user
Not applicable
Thank you!

Yes, one gets among one of > 1000 notes in a large log file something like at the bottom at least.

No chance to see that if you don't spend half a day just to read every word in your logfile.

The only thing I can conclude:
To train myself into doing searches for 3 words more or less automatically every time I have a look in a log file:
1. "error"
2. "warning"
3. "uninitialized"

Is that common use and knowledge in the SAS user community? Or is there another way to cope with that? By instance a switch or configuration issue to prevent this autodeclarations at all?

Thank you in advance!

Christof








NOTE: SAS initialization used:
real time 0.16 seconds
cpu time 0.08 seconds


NOTE: AUTOEXEC processing beginning; file is /opt/sas/sas9root/autoexec.sas.


NOTE: AUTOEXEC processing completed.

1 data test;
2
3 length x 3.;
4 input x;
5
6 datalines;

NOTE: The data set WORK.TEST has 3 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.02 seconds


10 ;
11 run;
12
13
14 data x;
15 set test;
16 y=0;
17 if (x2=1) then y=1;
18 run;

NOTE: Variable x2 is uninitialized.
NOTE: There were 3 observations read from the data set WORK.TEST.
NOTE: The data set WORK.X has 3 observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds


19
20

NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414
NOTE: The SAS System used:
real time 0.71 seconds
cpu time 0.25 seconds

The SAS System
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
For diagnosing your SAS program, there are other messages in addition to those mentioned, such as one about "...SAS did you a favor and converted a character variable to numeric..." -- sometimes expected but sometimes (in my opinion) not expected, depending on the program DATA step intention.

Best to learn and understand each message type and content as they occur in your SAS experience evolution.

Another nuance with SAS is the lack of any warning/error when a SAS numeric variable is truncated due to a SAS variable LENGTH precision issue - no warning at all given.


Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 653 views
  • 0 likes
  • 3 in conversation