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.
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.
This is before the code is run:
And after:
I don't understand what you mean by assigning a value?
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.
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.
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.
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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.