Hi all, I have the following code
proc sort data = work.final;
by Grades;
run;
proc means data = work.final maxdec = 2 nonobs;
class Grades;
var Emotionality;
output out = FS (drop = _FREQ_) N = mean = std = min = max = / autoname;
run;
proc sort data = work.FS;
by descending _TYPE_;
run;
Which gives me a table
I'm now trying to change the variable names with the following code
data FS(drop = _TYPE_);
set work.FS;
label Average_grades_in_school = 'Group' N = 'Count' Mean = 'Average' Std_Dev = 'Standard_Deviation';
run;
And it gives me the same output. Could anyone give me some advice? Thank you in advance!
If you want to create an output DATASET instead of the report you pasted the photograph of then just include the name you want for the variables for a statistic after the equal sign that follows the keyword for that statistic
If you want to produce a printed report from the generated dataset then just use any reporting procedure, like proc print.
proc means data = work.final nway noprint;
class Grades;
var Emotionality;
output out = FS (drop = _FREQ_)
N = Count
mean = Average
std = StandardDeviation
min = Minimum
max = Maximum
;
run;
proc print data=fs noobs;
run;
If you want to change the column headings used when printing the dataset into a tabular report you might want to use a LABEL statement in the PROC PRINT step.
You're not changing variable names, you are changing the label on the variable.
Having said that, what is your concern here, do you want a table (such as the one you show) showing these labels; or do you want SAS data set with different variable names (as your title implies)?
data FS(drop = _TYPE_);
set work.FS;
label Average_grades_in_school = 'Group' N = 'Count' Mean = 'Average' Std_Dev = 'Standard_Deviation';
run;
And it gives me the same output. Could anyone give me some advice? Thank you in advance!
But you're not asking for output ... how are you creating output here? ... please explain.
Hi,
Yes. I'm changing the label on the variables, that's what I mean and thank you for the clarification. And I want a table showing these labels. By output, I mean the table itself. I've been up pretty much all night and my head is in a mess. Sorry about that.
If you want to create an output DATASET instead of the report you pasted the photograph of then just include the name you want for the variables for a statistic after the equal sign that follows the keyword for that statistic
If you want to produce a printed report from the generated dataset then just use any reporting procedure, like proc print.
proc means data = work.final nway noprint;
class Grades;
var Emotionality;
output out = FS (drop = _FREQ_)
N = Count
mean = Average
std = StandardDeviation
min = Minimum
max = Maximum
;
run;
proc print data=fs noobs;
run;
If you want to change the column headings used when printing the dataset into a tabular report you might want to use a LABEL statement in the PROC PRINT step.
proc print data=fs label;
var average_grades_in_school n mean std_dev;
run;
Also, if you use labels, don't make labels that have underscores where spaces should be. Make the labels look like correct English (or whatever other language you want it to be). The label should not be 'Standard_Deviation' with an underscore as if you were creating labels for the benefit of the computer, it should be 'Standard Deviation' with a space as if you were creating labels for the benefit of people.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.