Good morning everyone
I wanted to ask you how I can make the name that I am assigning to the etequieta be modified in the output of the table
data test; set test; label due_in_1_Fixed=due in one your or less fixed rate ; run; proc datasets librery=work; modify test; label due_in_1_Fixed=due in one your or less fixed rate; quit; proc print data=test label; label due_in_1_Fixed=due in one your or less fixed rate; var due_in_1_Fixed; run;
*Create sample dataset to apply label;
data class;
set sashelp.class;
label Sex="Gender" height="Height (in)"weight="Weight (lbs)";
run;
title 'Show labels';
proc print data=class(obs=5) label noobs;
run;
title 'Override labels';
proc print data=class(obs=5) label noobs;
label height ="Height (cm)" weight="Weight (kgs)";
run;
@Herrera524 wrote:
Good morning everyone
I wanted to ask you how I can make the name that I am assigning to the etequieta be modified in the output of the table
data test; set test; label due_in_1_Fixed=due in one your or less fixed rate ; run; proc datasets librery=work; modify test; label due_in_1_Fixed=due in one your or less fixed rate; quit; proc print data=test label; label due_in_1_Fixed=due in one your or less fixed rate; var due_in_1_Fixed; run;
I tried to do it according to the example that you shared with me but it does not assign the label to the column name
@Herrera524 wrote:
I tried to do it according to the example that you shared with me but it does not assign the label to the column name
The code from @Reeza works for me.
It is never sufficient to say code does not work, and provide no other information. Specifically, from now on when code doesn't work, show us the code AND show us what is wrong — either show us the incorrect results, or if there are errors in the log then please show us the entire log for this piece of code
Hi
The code works perfectly for me, but it does not generate the expected result. According to the example, to the Height column I added the label "deu in one year or less fixed rate" which is what I want to appear in the name of the variable , but I still get Height,
How can I make the label appear instead of the name?
Changing a label does not change the variable name.
However, when you do a PROC PRINT with the LABEL option, then the label appears on the output, the variable name does not appear.
@Herrera524 wrote:
Hi
The code works perfectly for me, but it does not generate the expected result. According to the example, to the Height column I added the label "deu in one year or less fixed rate" which is what I want to appear in the name of the variable
Where do you want that name change to appear?
SAS has variable name limits but you could change it to something less than 32 characters with spaces. I wouldn't recommend doing that because then you have to type it out, but it's doable.
option validvarname = any;
data class;
set sashelp.class;
rename height ='Height in inches'n; *note the n at the end to specify a variable name;
run;
allows any characters in DBMS column names to appear as valid characters in SAS variable names. Symbols, such as the equal sign (=) and the asterisk (*), must be contained in a 'variable-name'n
construct. You must use ANY whenever you want to read DBMS column names that do not follow the SAS naming conventions.
Up to 32 characters are allowed in a column name.
Any column name that is not unique when it is normalized is made unique by appending a count (0, 1, 2, and so on).
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/n0vnyuzncldjabn1923ug8svx7uh.htm
Where do you want that name change to appear?
It is for a report that I am creating and I need that name to appear in it. Thank you very much for your support
I'm going to use what you shared with me.
@Herrera524 wrote:
Where do you want that name change to appear?
It is for a report that I am creating and I need that name to appear in it. Thank you very much for your support
I'm going to use what you shared with me.
Every reporting procedure in SAS allows you to use labels instead of the variable name when it produces a report. In PROC PRINT, the LABEL option is needed. In PROC REPORT, labels are used automatically. In PROC TABULATE, I don't know if labels are used automatically.
If it's for a report, labels should be sufficient. If you can produce a reprex (basic reproducible example) someone can show you how labels can be utilized in that report, for example proc report, tabulate, freq. Labels are definitely the better solution as they don't have the 32 character limit like the variable name.
The whole point of labels is that it allows you a lot more freedom to provide text to describe a variable than the variable name allows; it is also much more convenient to put this text into the variable label, not the variable name. As @Reeza points out, if you want that long text string as the variable name, that's a lot to type each time you want to use this variable (and don't make a spelling error!)
Almost all SAS procedures allow you to use the label in the output. So, there may be rare cases (emphasis on rare) where labels don't do the job, but really, in virtually every case I can think of, this text ought to go in the label and not the variable name.
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.
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.