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

I am trying to split the formmated xasix values in two lines with PROC SGPLOT but it is not working. Anybody has idea how to do that with SGPLOT (not GCHART)?

 

 
ods html gpath="&figuredir" image_dpi=200 ;
ods graphics/reset=index scale=off /*border=off*/ imagename="Descriptive Figure - PGA v1" width=10in height=6.5in;
title1 "Disease activity of patients remaining on adalimumab by month";
footnote;

proc sgplot data=freq dattrmap=attrmap2;
   vbar time / group=pgagrp  response=percent2  name="grouping"   BARWIDTH=0.7 NOOUTLINE  attrid=pgagrp     ;
   xaxis type=linear values=(0 to 36 by 3) label="Month (ADA/N)" fitpolicy=split SPLITCHAR=" ";
   yaxis label='Percent' values=(0 to 100 by 10);
   keylegend "grouping"   ;
   format   pgagrp pgagrptwo. time tfmttwo. percent2 7.1;
run;

ods graphics off;

Descriptive Figure - PGA v1.png

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

Aah, that's right.  It collapses all the blanks together into one blank value.  You will need to use non breaking space for each of the blank value.  Note, each one has to be different, so they don't get lumped into one category.  See:  http://blogs.sas.com/content/graphicallyspeaking/2012/09/03/doing-more-with-nbsp/

 

View solution in original post

13 REPLIES 13
DanH_sas
SAS Super FREQ

Use the SPLITALWAYS fitpolicy instead of the SPLIT policy. The SPLIT policy splits only when there is a collision.

jaemin
Calcite | Level 5

I just tried fitpolicy=SPLITALWAYS but it did not work.

DanH_sas
SAS Super FREQ

Sorry, I just picked up on the fact that you are using TYPE=LINEAR. In that case, the SPLIT policies have no effect. They work only for DISCRETE axes.

jaemin
Calcite | Level 5

The value is numeric but the formatted value is discrete. SAS does not have options for that situation?

ballardw
Super User

Can you show us what your  tfmttwo format definition looks like?

jaemin
Calcite | Level 5

Here is the format:

 

Capture.PNG

 
Jay54
Meteorite | Level 14

Here is a workaround.  You could remove the TYPE=Linear, and keep the discrete behavior.  Include all values 1-36 by 3 in the category column, with missing response for the ones you don't want (15, 21, etc).  Then, you can get the gaps on the x axis, and set FitPolicy=SplitAlways.  Use format or VALUESDISPLAY to control x-axis tick display.

jaemin
Calcite | Level 5

I edited the format and removed TYPE=LINEAR. Now it splits but how can I hide the values I don't want: 15, 21, 27. 33?

 

Capture.PNG

ods html gpath="&figuredir" image_dpi=200 ;
ods graphics/reset=index scale=off /*border=off*/ imagename="test" width=10in height=6.5in;
title1 "Disease activity of patients remaining on adalimumab by month";
proc sgplot data=freq dattrmap=attrmap2;
   vbar time / group=pgagrp  response=percent2  name="grouping"   BARWIDTH=0.7 NOOUTLINE  attrid=pgagrp     ;
   xaxis    values=(0 to 36 by 3)       label="Month (ADA/N)" fitpolicy=SPLITALWAYS  SPLITCHAR=" ";
   yaxis label='Percent' values=(0 to 100 by 10);
   keylegend "grouping"   
   format   pgagrp pgagrptwo. time tfmttwo. percent2 7.1;
run;
ods graphics off;

test.png

 

Jay54
Meteorite | Level 14

Cool.  Two ways.  One, you can put that in your format, make those values blank.  Or, you can use VALUESDISPLAY option on the x-axis.

jaemin
Calcite | Level 5

I tried making them blank in the format but I don't think it worked.

 

test.png

Jay54
Meteorite | Level 14

Aah, that's right.  It collapses all the blanks together into one blank value.  You will need to use non breaking space for each of the blank value.  Note, each one has to be different, so they don't get lumped into one category.  See:  http://blogs.sas.com/content/graphicallyspeaking/2012/09/03/doing-more-with-nbsp/

 

Jay54
Meteorite | Level 14

If your UDF is not aggregating data, then you could try putting the format on the VALUESFORMAT option on the axis and not on the column.  Would be easier to help if you attach the full program with data so we can run it and try various options.

jaemin
Calcite | Level 5

I used the method

xaxis=translate(xaxis, 'A0'x, '.');

you described in the webpage to create the format and it worked!!! Thanks so much!!!

 

data time_all2;
 merge tfmt time_all;
  by time;
  if time=15 then tlabel=put(time,best12.)||"="||quote('.') ;
  if time=21 then tlabel=put(time,best12.)||"="||quote('..') ;
  if time=27 then tlabel=put(time,best12.)||"="||quote('...') ;
  if time=33 then tlabel=put(time,best12.)||"="||quote('....') ;
  	tlabel2=translate(tlabel, 'A0'x, '.');
run;

proc sql;
 select tlabel2 into :tlabel separated by " "
  from time_all2;
quit;

proc format;
 value tfmttwo &tlabel  ;
run; 
proc sgplot data=freq dattrmap=attrmap2;
   vbar time / group=pgagrp  response=percent2  name="grouping"   BARWIDTH=0.7 NOOUTLINE  attrid=pgagrp     ;
   xaxis    values=(0 to 36 by 3)     label="Month (ADA/N)" fitpolicy=SPLITALWAYS  SPLITCHAR=" "   ;
   yaxis label='Percent' values=(0 to 100 by 10);
   keylegend "grouping"   ;
   format   pgagrp pgagrptwo. time tfmttwo. percent2 7.1;
run;

Capture.PNG

test.png

 

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
  • 13 replies
  • 6444 views
  • 0 likes
  • 4 in conversation