Write and run SAS programs in your web browser

Note: Variable GandBd1 is uninitialized.

Reply
Occasional Contributor
Posts: 7

Note: Variable GandBd1 is uninitialized.

Hi, 

I am getting that note for this variable and not for the rest of the variables even if I do a proc content this variable is listed (see attached). 

I tried to change the name, the values and I keep on getting that note and cannot do anything with this variable.

Does anybody know why?

Thank you for your help.

Perrine 

 


Screen Shot 2017-05-11 at 11.25.15 AM.png
Super User
Super User
Posts: 7,671

Re: Note: Variable GandBd1 is uninitialized.

What this note is telling you is that you have created a variable called gandbd1, however you have not in the datastep, assigned a value to any row.

Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

That is what I do not understand because there are values. See the attached screenshot. 

Thanks, 

Perrine


Screen Shot 2017-05-11 at 11.52.31 AM.png
Super User
Super User
Posts: 7,671

Re: Note: Variable GandBd1 is uninitialized.

And are they assigned in the same datastep as the variable is defined?  That is what the note is telling you.  For instance, I can get the same note with:

data want;
  length b $10;
run;
 

I create a variable called b, but in that dataste I assign no values to it.

Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

Here is my code: 

data missingdata;
set surv.HPLanalysis_xlsx;
if recall=3 then meantotveg=MEAN(Totvegd1,Totvegd1);
else if recall=2 then meantotveg=MEAN(Totvegd1);
if recall=3 then meantotGandB=MEAN(GandBd1,GandBd2);
else if recall=2 then meantotGandB=MEAN(GandBd1);
if recall=3 then meantotfruit=MEAN(Totfruitd1,Totfruitd2);
else if recall=2 then meantotfruit=MEAN(Totfruitd1);
run;

 

It works for the other variables but just not for GandBd1 and GandBd2. 

They are all from an excel that has similar variables in it. 

Thanks 

Super User
Super User
Posts: 7,671

Re: Note: Variable GandBd1 is uninitialized.

Yes, that doesn't help me.  Please post the dataset: set surv.HPLanalysis_xlsx;, as a datastep (just a few rows is fine) as text here.  You can follow this post:

https://communities.sas.com/t5/forums/replypage/board-id/sas_studio/message-id/2483

 

Also please , post the log of the part where this occurs, does the note follow this specific datastep, if so then the two given variables are not in that dataset and are getting create in this datastep, as as they are used in a condition never get assigned a value e.g to replicate:

data have;
  Totvegd1=12; output;
  Totvegd2=1; output;
run;
/* Note above does not contain gbandbd1 */
data want;
  set have;
  result1=mean(totvegd1,totvegd2);
  result2=mean(gbandbd1,totvegd1);
run;
Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

Here is the code and log:

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
59
60 data missingdata;
61 set surv.HPLanalysis_xlsx;
62 if recall=3 then meantotveg=MEAN(Totvegd1,Totvegd1);
63 else if recall=2 then meantotveg=MEAN(Totvegd1);
64 if recall=3 then meantotGandB=MEAN(GandBd1,GandBd2);
65 else if recall=2 then meantotGandB=MEAN(GandBd1);
66 if recall=3 then meantotfruit=MEAN(Totfruitd1,Totfruitd2);
67 else if recall=2 then meantotfruit=MEAN(Totfruitd1);
68 run;
 
NOTE: Variable GandBd1 is uninitialized.
NOTE: Variable GandBd2 is uninitialized.
NOTE: Missing values were generated as a result of performing an operation on missing values.
Each place is given by: (Number of times) at (Line)Smiley SadColumn).
42 at 64:31 8 at 65:36
NOTE: There were 80 observations read from the data set SURV.HPLANALYSIS_XLSX.
NOTE: The data set WORK.MISSINGDATA has 80 observations and 151 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
user cpu time 0.01 seconds
system cpu time 0.01 seconds
memory 1348.65k
OS Memory 28328.00k
Timestamp 05/11/2017 04:12:02 PM
Step Count 112 Switch Count 66
Page Faults 0
Page Reclaims 439
Page Swaps 0
Voluntary Context Switches 215
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 520
 
 
69
70 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
82
Super User
Super User
Posts: 7,671

Re: Note: Variable GandBd1 is uninitialized.

Ok, so:

NOTE: Variable GandBd1 is uninitialized.
NOTE: Variable GandBd2 is uninitialized
 
These do not exist in surv.HPLanalysis_xlsx;
At the time this dataset runs.  A picture of the contents after the event does not help, as after this note the variables do exist.  Run your code up to this step, don't run this step, stop before it.  Now check the contents of surv.HPLanalysis_xlsx;, you will see these variables do not exist.
Super User
Posts: 7,378

Re: Note: Variable GandBd1 is uninitialized.

Do a proc contents on surv.HPLanalysis_xlsx.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

The screenshot of the proc content is in my first post.


Screen Shot 2017-05-11 at 11.25.15 AM.png
Super User
Posts: 11,101

Re: Note: Variable GandBd1 is uninitialized.


Perrine wrote:

The screenshot of the proc content is in my first post.


And WHICH data set did you run that on? Missingdata or surv.HPLanalysis_xlsx? Yes the variables would be present in Missingdata as you just created them by referencing the variable name. The calculated values are missing because they use variables that are not in surv.HPLanalysis_xlsx.

Run Proc contents on surv.HPLanalysis_xlsx and show the complete result.

Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

The proc content is with surv.HPLanalysis_xlsx.

The screenshot is the same as previously attached.

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
59
60 proc contents data=surv.HPLanalysis_xlsx;
61 RUN;
 
NOTE: PROCEDURE CONTENTS used (Total process time):
real time 0.21 seconds
user cpu time 0.23 seconds
system cpu time 0.00 seconds
memory 3279.87k
OS Memory 29096.00k
Timestamp 05/11/2017 04:26:22 PM
Step Count 117 Switch Count 22
Page Faults 0
Page Reclaims 456
Page Swaps 0
Voluntary Context Switches 36
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 120
 
 
62
63 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
75
Occasional Contributor
Posts: 7

Re: Note: Variable GandBd1 is uninitialized.

So finally I found it when I did a proc contents with missingdata. There was a space in my column in excel before GandBd1....

Thank you for all your answers!

Super User
Posts: 7,378

Re: Note: Variable GandBd1 is uninitialized.

Post the code and log. Without that, we can only make guesses.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 13 replies
  • 198 views
  • 0 likes
  • 4 in conversation