BookmarkSubscribeRSS Feed
Diana__
Fluorite | Level 6

Hello,

I've been trying to label two variables correcta and correctb, but they keep getting deleted.

I'm using this:

Data HW4set;
set mylib.HW4;
LABEL
correcta = "Correct Answers Pretest"
correctb = "Correct Answers Posttest"
p1p = "Pretest Question 1";
Run;

The pretest and posttest questions (31 of them) all work with this code, but only the two variables correcta and correctb are 'uninitialized,' which I don't understand because they're in that data set as variables. The only difference is that they're created variables.

7 REPLIES 7
CurtisMackWSIPP
Lapis Lazuli | Level 10

What do you mean by created variables? That message is just telling you they were never assigned a value.  They should still be in the output dataset.  

If you assign them a value, that message will not come up.

Diana__
Fluorite | Level 6

This is before the code is run:

Diana___1-1601317754169.png

 

And after:

Diana___0-1601317675819.png

 

I don't understand what you mean by assigning a value?

 

CurtisMackWSIPP
Lapis Lazuli | Level 10

You screen shots are of tables that do not reflect the code you submitted.  There are many more variable that the results screen shot that are to the left of the variable being shown. 

 

Is it possible you are confusing the variable labels with the names?  By default the table viewer shows the variable labels, not the names.

PGStats
Opal | Level 21

Assigning a new label to a variable doesn't delete it.  I suspect that the BEFORE dataset you are looking at is not the dataset that your code is reading (in library MYLIB).

 

Also, if you are working within SAS Studio, make sure you refresh your view when you recreate a dataset; SAS Studio doesn't do it for you.

PG
data_null__
Jade | Level 19

Giving a variable (that does not exist) a label is not enough to create the variable.  For example...

 

7    data test;
8       set sashelp.class;
9       label correcta='This is a label';
10      run;

NOTE: Variable correcta is uninitialized.
NOTE: There were 19 observations read from the data set SASHELP.CLASS.
NOTE: The data set WORK.TEST has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds

And the contents of TEST.

Capture.PNG

 

PGStats
Opal | Level 21

Isn't that a confusing message, about a variable that doesn't exist? I would prefer

 

NOTE: A label was assigned to nonexistent variable correcta.

PG
Kurt_Bremser
Super User

By using them in the LABEL statement, you defined the variables, but you never assigned them a value. That's why you get the "uninitialized" NOTE, and they only contain missing values.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 685 views
  • 0 likes
  • 5 in conversation