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

 

proc sgplot data=anl317.uscrime;
	vbox victim age;
run;

the code above results in an error labelled: 

ERROR: Variable VICTIM not found.
 
anyone have any idea what I can change to my code for it to work?
I have tried "Victim Age", Victim Age, victimage, all does not work.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

If there is a space in a variable name, you can try using a name literal:

 

proc sgplot data=anl317.uscrime;
	vbox "Victim Age"n;
run;

It's a hassle,  sometimes it is easier to rename the variable to remove the space, e.g.:

 

data uscrime;
  set anl317.uscrime (rename=("Victim Age"n=VictimAge));
run;

proc sgplot data=uscrime;
	vbox VictimAge;
run;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.

View solution in original post

4 REPLIES 4
Reeza
Super User

Run a proc contents on the data set and confirm the variable name. Victim may be the label, not the variable name.

 

proc contents data=anl317.uscrime;
run;

@MengWei wrote:

 

proc sgplot data=anl317.uscrime;
	vbox victim age;
run;

the code above results in an error labelled: 

ERROR: Variable VICTIM not found.
 
anyone have any idea what I can change to my code for it to work?
I have tried "Victim Age", Victim Age, victimage, all does not work.

 

 


 

MengWei
Calcite | Level 5

Screenshot 2024-02-17 at 12.06.36 AM.png

 Victim Age is the variable name though, it does not work.

Quentin
Super User

If there is a space in a variable name, you can try using a name literal:

 

proc sgplot data=anl317.uscrime;
	vbox "Victim Age"n;
run;

It's a hassle,  sometimes it is easier to rename the variable to remove the space, e.g.:

 

data uscrime;
  set anl317.uscrime (rename=("Victim Age"n=VictimAge));
run;

proc sgplot data=uscrime;
	vbox VictimAge;
run;
The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
MengWei
Calcite | Level 5
thanks! tried the first code and it worked

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 896 views
  • 7 likes
  • 3 in conversation