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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

6 REPLIES 6
smunigala
Obsidian | Level 7
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

Cynthia_sas
SAS Super FREQ
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
ballardw
Super User

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.

 

smunigala
Obsidian | Level 7

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

 

Satish

Ksharp
Super User

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

smunigala
Obsidian | Level 7

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

 

Satish

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 6 replies
  • 4102 views
  • 1 like
  • 4 in conversation