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

Hello,

 

I have the number of people by age. My numeric variable of age category ' Cat_age ' was coded in 1,2,3.

1='3-5 years'
2='6-11 years'
3='12-18 years'

 

I would like to draw a graph with the number of people by age. So i used a proc format to display in my graph "3-5 years' instead of "1" but it doesn't seem to work... The graph displays me column with 1,2,3 in the horizontal axis. Ci-below my script (i am a beginner in SAS ...).

 

Thanks in advance,

 

title 'Age distribution';

axis1 stagger label=('Âge');
axis2 label=('Effectif');

proc format;
   value cat_age 1='3-5 ans'
                	   2='6-11 ans'
		           3='12-18 ans';
run;

proc gchart data=conso;
   vbar cat_age /discrete maxis=axis1 raxis=axis2;
   format cat_age;
run;
quit; 

cat_age.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Your methodology is correct but syntax isn't.

 

The syntax is 

 

FORMAT variable_name(s) format_name.;

So in your case, since you've named the format the same as the variable name:

Format cat_age cat_age.;

View solution in original post

3 REPLIES 3
Reeza
Super User

Your methodology is correct but syntax isn't.

 

The syntax is 

 

FORMAT variable_name(s) format_name.;

So in your case, since you've named the format the same as the variable name:

Format cat_age cat_age.;
Foody
Fluorite | Level 6

Thank you ! Now it works !

proc gchart data=conso;
   vbar cat_age /discrete maxis=axis1 raxis=axis2;
   format cat_age cat_age.;
run;
quit; 
Reeza
Super User

If you have the option switch to SGPLOT instead, you get better graphics and more supported. 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 1720 views
  • 1 like
  • 2 in conversation