BookmarkSubscribeRSS Feed
vanmon1
Obsidian | Level 7

Hi, I would like to add a second vbar so the graph shows the region at the bottom as well as the village by the x axis

like in the excel graph attached. Thank you in advance. 

Jef_mto variable is 'J.A.MTO.BARCELONA' , J.A.MTO.ZARAGOZA' ,J.A.MTO.TARRAGONA' in the graph.

vbar = Garraf, Castelldefells,Balenya-Tona-Seva etc



proc sgplot data=peores_all dattrmap=attrmap;
    vbar  denominacion_estacion  / response=Tasa_fallo  group=mes  grouporder=descending stat=sum attrid=myid ;
	/*styleattrs datacolors=(red brown orange yellow darkgreen green lightgreen);*/

   xaxis label='estacion' discreteorder=data 
labelattrs=( size=7pt )
    valueattrs=( size=7pt )
	fitpolicy=rotate
	valuesrotate=vertical;
   yaxis label='';
   
   title '';
   keyLegend / title='Mes';
   by subdireccion  jef_mto tipo_cv  /*I would like to move jef_mto variable so the graphs look like the attached*/
	
;
    run; quit;

	ods pdf close;

PHOTO GRAPH.png

5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

For any graph questions its best to look here:

http://blogs.sas.com/content/graphicallyspeaking/

 

First, as there is examples of anything graph orientated with code.

 

Here for instance is one showing data below the graph:

https://blogs.sas.com/content/graphicallyspeaking/2017/08/08/tips-and-tricks-transparent-margins/

 

You may just not draw the X on the first graph, draw the second under it and put the X axis for that one.

Jay54
Meteorite | Level 14

For this case, I suggest using SGPANEL with region as the panel variable in the PANELBY statement with the PROPORTIONAL option .

vanmon1
Obsidian | Level 7

ExcelExcelSGPANELSGPANELMy SGPLOT with missing regionMy SGPLOT with missing regionSanjay_SAS, thank you for your reply. I don't know much about ods graphics. I see the sgpanel may help me but then I loose all the other settings. Please see attachemnts with sgplot and sgpanel. 

I have three levels of data Subdireccion (like State), Jef_mto (like region) and the vbar denominacion_estacion (like village). 

I need to show in one by the State, the villages divided by their region. And also, keep the order of the response by the group=mes (month) . Sgpanel mixes the states when the number of regions is an odd number (attached).

Thank you.

 

/*proc sgpanel*/
	proc sgpanel data=peores_all dattrmap=attrmap;
	panelby subdireccion jef_mto tipo_cv;
	rowaxis label="estación";
	vbar denominacion_estacion /response=Tasa_fallo group=mes  grouporder=descending stat=sum attrid=myid ;
	
	run;



/*sgplot*/

ods pdf file="\\tsclient\C\Transferencia de Archivos\EXPORTED FINAL TABLE\'Peores jefaturas CVs.pdf";

ODS GRAPHICS/ WIDTH=20.32CM ;
data attrmap;
retain id "myid";
input value $ fillcolor $;
datalines;

2017-10 red 
2017-09 brown 
2017-08 orange 
2017-07 yellow 
2017-06 big 
2017-05 bilg 
2017-04 bigy
2017-03 bigy
2017-02 grey
2017-01 grey
2016-12 grey
2016-11 grey
2016-10 grey
2016-09 grey
2016-08 grey
2016-07 grey
2016-06 grey
2016-05 grey
2016-04 grey
2016-03 grey
2016-02 grey
2016-01 grey
2015-12 grey
2015-11 grey
2015-10 grey
2015-09 grey
2015-08 grey
2015-07 grey
2015-06 grey
2015-05 grey
2015-04 grey
2015-03 grey
2015-02 grey
2015-01 grey
run;





proc sgplot data=peores_all dattrmap=attrmap;
    vbar  denominacion_estacion / response=Tasa_fallo  group=mes  grouporder=descending stat=sum attrid=myid ;
	/*styleattrs datacolors=(red brown orange yellow darkgreen green lightgreen);*/

   xaxis label='estacion' discreteorder=data 
labelattrs=( size=7pt )
    valueattrs=( size=7pt )
	fitpolicy=rotate
	valuesrotate=vertical;
   yaxis label='';
   
   title '';
   keyLegend / title='Mes';
   by subdireccion  tipo_cv 
	
;
    run; quit;

	ods pdf close;

region. Like in the excel.

SGPanel28.pngSGPlot730.png

Jay54
Meteorite | Level 14

Clearly, you have too many categories per cell which results in many diagonal tick values.  If you attach your full program and sample data (not your confidential data), it will be easier to help.

Jay54
Meteorite | Level 14

 

Here is a sample using sashelp.prdsale.

 

Vanmon1.png

 

 

data prdsale;
set sashelp.prdsale;
if ~(country='GERMANY' and (product="BED" or product="CHAIR"));
run;

 

ods html close;
ods listing gpath='C:\Work\SASUser\Communities\Image' image_dpi=200;
ods graphics / reset width=6in height=4in imagename='Vanmon1';
proc sgpanel data=prdsale ;
  by year;
  panelby country / onepanel layout=columnlattice colheaderpos=bottom
               noheaderborder novarname noborder proportional uniscale=row spacing=20;
  vbar product / stat=sum group=month response=actual displaybaseline=auto
           barwidth=0.5 dataskin=pressed;
  colaxis fitpolicy=rotate valuesrotate=vertical display=(nolabel noticks noline);
  rowaxis display=(nolabel noticks noline) grid;
  keylegend / across=6 title='';
run;

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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
  • 5 replies
  • 4221 views
  • 0 likes
  • 3 in conversation