The SAS Output Delivery System and reporting techniques

Different color options for my vbar statement on PROC SGPANEL

Accepted Solution Solved
Reply
Contributor
Posts: 59
Accepted Solution

Different color options for my vbar statement on PROC SGPANEL

Hi guys,

Please help me out with the SAS code for generating different color bars for my code.

 

Here is my code:

Fig 2a New Sep18.jpeg

 

*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


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
Super User
Posts: 9,865

Re: Different color options for my vbar statement on PROC SGPANEL

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;

download.png

View solution in original post


All Replies
Contributor
Posts: 59

Re: Different color options for my vbar statement on PROC SGPANEL

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

SAS Super FREQ
Posts: 8,818

Re: Different color options for my vbar statement on PROC SGPANEL

Hi:
There is a separate community for ODS GRAPHICS and SAS/GRAPH questions and generally, all the graph folks hang out over there. You might want to consider posting your question over in that community.
cynthia
Super User
Posts: 11,114

Re: Different color options for my vbar statement on PROC SGPANEL

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.

 

Contributor
Posts: 59

Re: Different color options for my vbar statement on PROC SGPANEL

Thanks for the reply ballard. I am attacging a text file of my excel sheet. Hope this helps how my data is structured.

 

Satish

Solution
‎09-25-2015 06:23 AM
Super User
Posts: 9,865

Re: Different color options for my vbar statement on PROC SGPANEL

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;

download.png

Contributor
Posts: 59

Re: Different color options for my vbar statement on PROC SGPANEL

Thank you all! Ksharp your code works well and thanks for the help.

 

Satish

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 1021 views
  • 1 like
  • 4 in conversation