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

Hi Everyone,

 

I'm doing the online SAS Programming 1 class and I'm having trouble getting my labels to show in SAS Enterprise Guide.  We're using the sashelp.cars table and this is in activity p105a04. 

We're supposed to use a data statement to assign permanent labels to some columns, then run the means and print procedures with the output using the labels rather than the original column names.

This is the code that I have, which matches exactly with what the solution has:

 

data cars_update;
    set sashelp.cars;
    keep Make Model MSRP Invoice AvgMPG;
    AvgMPG=mean(MPG_Highway, MPG_City);
    label MSRP="Manufacturer Suggested Retail Price"
    AvgMPG="Average Miles per Gallon"
    Invoice="Invoice Price";
run;

proc means data=cars_update min mean max;
    var MSRP Invoice;
run;

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
run;

 

The labels for the columns should be replaced with my new labels (eg. MRSP should be "Manufacturer Suggested Retail Price"), but it's only showing the original column names. 

Here's what the output tables look like:

 

Ex1.PNG

 

I looked at proc contents like she did in the lesson, but the labels weren't in there.  

Ex2.PNG

 

I also tried using the proc print statement with temporary labels, but the labels didn't show up for that either:

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
    label MSRP="Manufacturer Suggested Retail Price"
             AvgMPG="Average Miles per Gallon"
             Invoice="Invoice Price";
run;

Ex3.PNG

 

 

Any help would be greatly appreciated!  

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@whyknock wrote:

Hi Everyone,

 

I'm doing the online SAS Programming 1 class and I'm having trouble getting my labels to show in SAS Enterprise Guide.  We're using the sashelp.cars table and this is in activity p105a04. 

We're supposed to use a data statement to assign permanent labels to some columns, then run the means and print procedures with the output using the labels rather than the original column names.

This is the code that I have, which matches exactly with what the solution has:

 

data cars_update;
    set sashelp.cars;
    keep Make Model MSRP Invoice AvgMPG;
    AvgMPG=mean(MPG_Highway, MPG_City);
    label MSRP="Manufacturer Suggested Retail Price"
    AvgMPG="Average Miles per Gallon"
    Invoice="Invoice Price";
run;

proc means data=cars_update min mean max;
    var MSRP Invoice;
run;

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
run;

 

The labels for the columns should be replaced with my new labels (eg. MRSP should be "Manufacturer Suggested Retail Price"), but it's only showing the original column names. 

Here's what the output tables look like:

 

Ex1.PNG

 

I looked at proc contents like she did in the lesson, but the labels weren't in there.  

Ex2.PNG

 

I also tried using the proc print statement with temporary labels, but the labels didn't show up for that either:

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
    label MSRP="Manufacturer Suggested Retail Price"
             AvgMPG="Average Miles per Gallon"
             Invoice="Invoice Price";
run;

Ex3.PNG

 

 

Any help would be greatly appreciated!  

Thanks in advance!


Try running this code and then check the log:

proc options option=label;
run;

If you see something like this:

 

 NOLABEL           Disables procedures from using labels with variables.

then someone set a system option not to display labels. Which should be fixable with

 

option label;

 

If you don't see the NOLABEL then I would re-run your data step creating cars_update and verify that it was successfully created by checking the LOG. The symptom you describe sounds more like you created the set and then modified the code to add the labels and either did not rerun the code or that there was an error and the data set was not replaced for some reason such as open in view table mode or a syntax error.

View solution in original post

2 REPLIES 2
ballardw
Super User

@whyknock wrote:

Hi Everyone,

 

I'm doing the online SAS Programming 1 class and I'm having trouble getting my labels to show in SAS Enterprise Guide.  We're using the sashelp.cars table and this is in activity p105a04. 

We're supposed to use a data statement to assign permanent labels to some columns, then run the means and print procedures with the output using the labels rather than the original column names.

This is the code that I have, which matches exactly with what the solution has:

 

data cars_update;
    set sashelp.cars;
    keep Make Model MSRP Invoice AvgMPG;
    AvgMPG=mean(MPG_Highway, MPG_City);
    label MSRP="Manufacturer Suggested Retail Price"
    AvgMPG="Average Miles per Gallon"
    Invoice="Invoice Price";
run;

proc means data=cars_update min mean max;
    var MSRP Invoice;
run;

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
run;

 

The labels for the columns should be replaced with my new labels (eg. MRSP should be "Manufacturer Suggested Retail Price"), but it's only showing the original column names. 

Here's what the output tables look like:

 

Ex1.PNG

 

I looked at proc contents like she did in the lesson, but the labels weren't in there.  

Ex2.PNG

 

I also tried using the proc print statement with temporary labels, but the labels didn't show up for that either:

proc print data=cars_update label;
    var Make Model MSRP Invoice AvgMPG;
    label MSRP="Manufacturer Suggested Retail Price"
             AvgMPG="Average Miles per Gallon"
             Invoice="Invoice Price";
run;

Ex3.PNG

 

 

Any help would be greatly appreciated!  

Thanks in advance!


Try running this code and then check the log:

proc options option=label;
run;

If you see something like this:

 

 NOLABEL           Disables procedures from using labels with variables.

then someone set a system option not to display labels. Which should be fixable with

 

option label;

 

If you don't see the NOLABEL then I would re-run your data step creating cars_update and verify that it was successfully created by checking the LOG. The symptom you describe sounds more like you created the set and then modified the code to add the labels and either did not rerun the code or that there was an error and the data set was not replaced for some reason such as open in view table mode or a syntax error.

whyknock
Calcite | Level 5

Thank you!  It worked perfectly.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 8724 views
  • 2 likes
  • 2 in conversation