BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aabbccwyt
Obsidian | Level 7

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

Screen Shot 2021-12-11 at 9.35.12 PM.png

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
aabbccwyt
Obsidian | Level 7

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.

Tom
Super User Tom
Super User

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.

PaigeMiller
Diamond | Level 26
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.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2833 views
  • 0 likes
  • 3 in conversation