How many characters can be used in a label?
a. 96
b. 200
c. 256
d. 32,767
sas prep guide answer is 32,767,
but everywhere i searched l it is 256
The documentation for the LABEL statement is very clear.
Hi @vidyapedii,
Also, the context of the question is relevant: If "label" means a formatted value in a format definition, then 32,767 is correct, whereas a variable label and a data set label have a maximum length of 256. (In the context of graphics there are axis labels, tick mark labels, ...)
So, @vidyapedii, following up on the point by @FreelanceReinh, what is the exact wording of the question?
I, too, prefer the doc, but you can also write a program to experiment/validate. Here is a program that makes a string of length N and puts it into a macro variable (which also has a maximum length). If you use this value in the LABEL statement to set a variable label, you can see whether it works for 257 length:
%let N = 257;
data _NULL_;
length L $&N;
L = subpad("A",1,257);
call symput("lbl", L);
run;
data Want;
label A = "&lbl";
a = 1;
run;
For this program, you get the following WARNING:
WARNING: Label value for variable A has been truncated to a length of 256
bytes.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.