Hi guys,
Please help me out with the SAS code for generating different color bars for my code.
Here is my code:
*Fig 2a;
ods listing close;
ods graphics / reset width=600px height=400px imagename='Fig 2a New Sep18' imagefmt=jpeg;
ods html file='Surg.html' path='C:\Users\smunigal\Desktop\ID-Personal\NIS_Surgery\Tables_Figs' ;
proc sgpanel data=Panc_cond;
panelby type / layout=columnlattice uniscale=row novarname spacing=40
colheaderpos=bottom;
colaxis display =(nolabel);
rowaxis max=150;
/* to keep the bars the same width, add the PROPORTION option */
label ADJ_PANC ='Rate Per Million';
vbarparm group = ADJ_PANC/ category=GROUP response=ADJ_PANC /
limitlower=ADJ_PANC_LOW limitupper=ADJ_PANC_HIGH barwidth=0.6;
run;
ods html close;
ods listing;
So basically I need different color for my age group bars;
different color for sex bars;
different color for RACE bars;
Thanks a lot,
Satish
As Cynthia pointed it is a Graph problem. Better post it at Graph Forum.
data have;
infile cards truncover dlm='09'x;
input YEAR : $20. TYPE : $20. GROUP : $20. ADJ_PANC ADJ_PANC_LOW ADJ_PANC_HIGH;
cards;
1998-2011 Sex MALE 50.3 45.03 55.57
1998-2011 Sex FEMALE 47.83 42.61 53.04
1998-2011 Age Group 18-24 6.68 5.74 7.63
1998-2011 Age Group 25-34 12.77 11.25 14.29
1998-2011 Age Group 35-44 26.38 23.46 29.29
1998-2011 Age Group 45-54 48.95 43.67 54.23
1998-2011 Age Group 55-64 83 73.68 92.32
1998-2011 Age Group 65+ 119.7 106.15 133.24
1998-2011 Race BLACK 108.7 87.11 130.3
1998-2011 Race WHITE 59.44 45.02 73.86
;
run;
proc sgpanel data=have;
panelby type / layout=columnlattice uniscale=row novarname spacing=40
colheaderpos=bottom;
colaxis display =(nolabel);
rowaxis max=150;
/* to keep the bars the same width, add the PROPORTION option */
label ADJ_PANC ='Rate Per Million';
vbarparm category=GROUP response=ADJ_PANC / group=group
limitlower=ADJ_PANC_LOW limitupper=ADJ_PANC_HIGH barwidth=0.6;
run;
ods listing close;
ods graphics / reset width=600px height=400px imagename='Fig 2a New Sep18' imagefmt=jpeg;
ods html file='Surg.html' path='C:\Users\smunigal\Desktop\ID-Personal\NIS_Surgery\Tables_Figs' ;
proc sgpanel data=Panc_cond;
panelby type / layout=columnlattice uniscale=row novarname spacing=40
colheaderpos=bottom;
colaxis display =(nolabel);
rowaxis max=150;
/* to keep the bars the same width, add the PROPORTION option */
label ADJ_PANC ='Rate Per Million';
vbarparm category=GROUP response=ADJ_PANC /
limitlower=ADJ_PANC_LOW limitupper=ADJ_PANC_HIGH barwidth=0.6;
run;
ods html close;
ods listing;
Here is the updated SAS code. Sorry there were typos in my original statement.
Thanks,
Satish
One approach to accomplish what I believe you are looking for is a subgroup but with missing values for the response variable except for a specific level. This does require the data to be presummarized before the graphing procedure. You don't provide any example data but something like this may give you an idea;
Data example;
input type $ group $ adj_panc subgroup ;
datalines;
Age 18-24 10 1
Age 18-24 . 2
Age 18-24 . 3
Age 25-34 . 1
Age 25-34 20 2
Age 25-34 . 3
Age 35-44 . 1
Age 35-44 . 2
Age 35-44 30 3
.;
run;
The idea is that there isn't a value for the other subgroups so they don't get displayed in the stack but are a different level so get assigned a different color.
Thanks for the reply ballard. I am attacging a text file of my excel sheet. Hope this helps how my data is structured.
Satish
As Cynthia pointed it is a Graph problem. Better post it at Graph Forum.
data have;
infile cards truncover dlm='09'x;
input YEAR : $20. TYPE : $20. GROUP : $20. ADJ_PANC ADJ_PANC_LOW ADJ_PANC_HIGH;
cards;
1998-2011 Sex MALE 50.3 45.03 55.57
1998-2011 Sex FEMALE 47.83 42.61 53.04
1998-2011 Age Group 18-24 6.68 5.74 7.63
1998-2011 Age Group 25-34 12.77 11.25 14.29
1998-2011 Age Group 35-44 26.38 23.46 29.29
1998-2011 Age Group 45-54 48.95 43.67 54.23
1998-2011 Age Group 55-64 83 73.68 92.32
1998-2011 Age Group 65+ 119.7 106.15 133.24
1998-2011 Race BLACK 108.7 87.11 130.3
1998-2011 Race WHITE 59.44 45.02 73.86
;
run;
proc sgpanel data=have;
panelby type / layout=columnlattice uniscale=row novarname spacing=40
colheaderpos=bottom;
colaxis display =(nolabel);
rowaxis max=150;
/* to keep the bars the same width, add the PROPORTION option */
label ADJ_PANC ='Rate Per Million';
vbarparm category=GROUP response=ADJ_PANC / group=group
limitlower=ADJ_PANC_LOW limitupper=ADJ_PANC_HIGH barwidth=0.6;
run;
Thank you all! Ksharp your code works well and thanks for the help.
Satish
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.
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.