Hi, this is my first time to use PROC GCHART to create a image on SAS, and I need some guidance for it.
Now I have a data set named information, and
my purpose is to use this data set to create a chart that shows:
1. From year 2007 to 2010, how many times GY1(Group Y 1), GY2, GY3 are ranked in each year. (numbers under the bar)
2. Within each year, the proportions are respectively that GY1, GY2, GY3 are ranked as 1st, 2nd, 3rd.(percentages within each bar)
3. Assign different colors to different rank class.
4. The image is in format GIF.
And here's one way to create a similar graph with SAS/Graph Gchart ...
data my_data;
input Group_Y_ID Year count rank_1st rank_2nd rank_3rd;
label rank_1st='1st Ranked' rank_2nd='2nd Ranked' rank_3rd='3rd Ranked';
datalines;
1 2007 3 66.66667 33.33333 0
1 2008 3 33.33333 33.3333 33.33333
1 2009 4 0 75 25
1 2010 4 50 50 0
2 2007 4 50 50 0
2 2008 3 33.33333 66.66667 0
2 2009 4 100 0 0
2 2010 5 80 20 0
3 2007 3 33.33333 33.33333 33.33333
3 2008 2 50 0 50
3 2009 3 33.33333 33.33333 33.33333
3 2010 4 25 75 0
;
run;
proc transpose data=my_data (drop=count) out=tran_data;
by Group_Y_ID year;
run;
data tran_data; set tran_data;
format col1 percentn6.0;
col1=col1/100;
run;
goptions xpixels=500 ypixels=450;
goptions gunit=pct htitle=3 ftitle="albany amt/bold" htext=2.5 ftext="albany amt";
legend1 label=none;
pattern1 v=s c=cxfad9b8;
pattern2 v=s c=cxadd7e5;
pattern3 v=s c=cxf7f8d0;
axis1 label=none value=none style=0 major=none minor=none;
axis2 label=none value=(angle=90) style=0;
axis3 label=none;
title1 ls=1.5 "Group Portfolio (2007 / 2008 / 2009 / 2010)";
proc gchart data=tran_data;
vbar year / discrete
group=Group_Y_ID
type=sum sumvar=col1 inside=sum
subgroup=_label_ legend=legend1
raxis=axis1 maxis=axis2 gaxis=axis3 noframe
width=8 space=0 coutline=white;
run;
And here's what the output looks like:
I got someone to fix the image uploads, and I'll go ahead and upload your images:
And here's one way to create a similar graph with SAS/Graph Gchart ...
data my_data;
input Group_Y_ID Year count rank_1st rank_2nd rank_3rd;
label rank_1st='1st Ranked' rank_2nd='2nd Ranked' rank_3rd='3rd Ranked';
datalines;
1 2007 3 66.66667 33.33333 0
1 2008 3 33.33333 33.3333 33.33333
1 2009 4 0 75 25
1 2010 4 50 50 0
2 2007 4 50 50 0
2 2008 3 33.33333 66.66667 0
2 2009 4 100 0 0
2 2010 5 80 20 0
3 2007 3 33.33333 33.33333 33.33333
3 2008 2 50 0 50
3 2009 3 33.33333 33.33333 33.33333
3 2010 4 25 75 0
;
run;
proc transpose data=my_data (drop=count) out=tran_data;
by Group_Y_ID year;
run;
data tran_data; set tran_data;
format col1 percentn6.0;
col1=col1/100;
run;
goptions xpixels=500 ypixels=450;
goptions gunit=pct htitle=3 ftitle="albany amt/bold" htext=2.5 ftext="albany amt";
legend1 label=none;
pattern1 v=s c=cxfad9b8;
pattern2 v=s c=cxadd7e5;
pattern3 v=s c=cxf7f8d0;
axis1 label=none value=none style=0 major=none minor=none;
axis2 label=none value=(angle=90) style=0;
axis3 label=none;
title1 ls=1.5 "Group Portfolio (2007 / 2008 / 2009 / 2010)";
proc gchart data=tran_data;
vbar year / discrete
group=Group_Y_ID
type=sum sumvar=col1 inside=sum
subgroup=_label_ legend=legend1
raxis=axis1 maxis=axis2 gaxis=axis3 noframe
width=8 space=0 coutline=white;
run;
And here's what the output looks like:
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.