BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Pranaysree
Fluorite | Level 6
How to rotate tick mark values at an angle of 45 degrees from bottom of left to top of right in sg plot ?

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

An option to rotate the tick values on a diagonal from bottom left to top right is planned for support in the next release.  It is not available in currently released software.  A workaround would be to use Annotate to insert such values on the x-axis.

View solution in original post

11 REPLIES 11
Rick_SAS
SAS Super FREQ

If you want to rotate the X axis labels, here is a link to the XAXIS documentation. Use the YAXIS statement if you want to rotate the labels for the vertical axis. Look up the FITPOLICY=ROTATE option.  Be aware, however, that the rotation only occurs if the labels are long and there would be a collision

 

To UNCONDITIONALLY rotate the axis labels, you would need to use the GTL. See the TICKVALUEPOLICY=ROTATEALWAYS option in the LAYOUT OVERLAY section of the GTL documentation.

Jay54
Meteorite | Level 14

An option to rotate the tick values on a diagonal from bottom left to top right is planned for support in the next release.  It is not available in currently released software.  A workaround would be to use Annotate to insert such values on the x-axis.

Pranaysree
Fluorite | Level 6
What is the code to Annotate ?
Jay54
Meteorite | Level 14

SGAnnotation is a whole topic on its own, not some code I can send you.  You can read up on it in the paper linked.  The idea is you have to turn off the default tick values and then insert each tick value at the right location on the x-axis rotated the way you want.  Not a trivial task. https://support.sas.com/resources/papers/proceedings11/277-2011.pdf

 

Pranaysree
Fluorite | Level 6

I have tried with this, but there is no result.

Pranaysree
Fluorite | Level 6

This is the details which I have followed.

ballardw
Super User

Many users here don't want to download Office  files because of virus potential, others have such things blocked by security software.

It is much better to post code and log examples into a code box in the forum, use the {i} menu icon.

 

Word documents are known to change plain code sometimes. A common issue being replacing a simple apostrophe ' or double quote " with "smart quotes" the curly versions. Also text format characters somtimes are hidden and when the code is copied from Word to the SAS editor the invisible characters interfere with code execution.

Pranaysree
Fluorite | Level 6

Thank You for your support. I have tried all logs. I am sending you all the logs which I have tried. Can you please check the log, do some necessary corrections in it and send me back one log which will give me the result. I cannot understand where to modify, so I have done up to my level. Below are my all logs. Just say what to write in the command in which log no. and which line no. in that log.

 

 

LOG DAT 0.

Log

189  * Plot with XAXIS and YAXIS;

190  proc template;

191  define style styles.LasVegas2;

192  parent = styles.default;

193  style GraphConfidence from GraphConfidence / color= CXE8D898;

194  style GraphLegendBackground / transparency=0;

195  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

196  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

197  style GraphBorderLines from GraphBorderLines / LineThickness=1;

198  *style GraphWalls from GraphWalls / color= CXC0C0C0;

199  style GraphBackground / transparency=1;

200  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

201  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

202  ODs graphics on;

203  HEIGHT = 4in WIDTH = 3in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

204  ODS html style=LasVegas2;

205

206  ODS LISTING GPATH = 'c:\MyGraphs';

207

208  data sganno;

209     retain function 'text' x1space 'datavalue' y1space 'datapercent'

210            rotate 45 anchor "right" width 30 textweight 'bold';

211     length textcolor $20;

212     set sashelp.class;

213     label=year;

214     xc1=year;

215     y1=-5;

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

NOTE: There were 19 observations read from the data set SASHELP.CLASS.

NOTE: The data set WORK.SGANNO has 19 observations and 17 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

 

216  PROC sgplot DATA = sashelp.class sganno=sganno pad=(bottom=15%);

217  Series X = year Y = Production/ markers markerattrs=(symbol=circlefilled);

ERROR: Variable YEAR not found.

ERROR: Variable PRODUCTION not found.

218  ;

219  series x=Year Y=Prediction/markers markerattrs=(symbol=circlefilled);

ERROR: Variable YEAR not found.

ERROR: Variable PREDICTION not found.

220  XAXIS LABEL = 'Year' values = (1979 TO 2026 BY 3) type=linear;

221  YAXIS LABEL = 'Production (tonne)' values = (200000 TO 600000 BY 100000);

222  TITLE 'Fig.1  total marine total fish production';

223  RUN;

 

NOTE: The SAS System stopped processing this step because of errors.

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

224  Ods graphics off;

 

 

LOG DATA 1.

 

log data

133  * Plot with XAXIS and YAXIS;

134  proc template;

135  define style styles.LasVegas2;

136  parent = styles.default;

137  style GraphConfidence from GraphConfidence / color= CXE8D898;

138  style GraphLegendBackground / transparency=0;

139  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, bold);

140  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

141  style GraphBorderLines from GraphBorderLines / LineThickness=1;

142  *style GraphWalls from GraphWalls / color= CXC0C0C0;

143  style GraphBackground / transparency=0;

144  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

145  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

146  ODs graphics on;

147  HEIGHT = 3in WIDTH = 4in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

148  ODS html style=LasVegas2;

149

150  ODS LISTING GPATH = 'c:\MyGraphs';

151

152  PROC SGPLOT DATA = bv ;

153  SERIES X = year Y = production /LINEATTRS=(thickness=3);

154  XAXIS LABEL = 'Year' values = (1979 TO 2027 BY 4) type=linear;

155  YAXIS LABEL = 'Production (tonnes)' values = (200000 TO 600000 BY 100000);

156  TITLE 'Marine total fish production';

157  RUN;

 

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.28 seconds

      cpu time            0.06 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot17.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

158  Ods graphics off;

159

160  PROC SGPLOT DATA=bv;

161  VLINE YEAR / RESPONSE=PRODUCTION;

162  XAXIS LABEL = 'Year' values = (1979 TO 2027 BY 4) type=linear;

163  XAXIS DISPLY=(NOLABEL);

           ------

           1

WARNING 1-322: Assuming the symbol DISPLAY was misspelled as DISPLY.

164  KEYLEGEND / POSITION=LEFT   VALUEATTRS=(SIZE=9PT);

165  run;

 

NOTE: Since no format is assigned, the numeric category variable will use the default of BEST6.

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.28 seconds

      cpu time            0.06 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot19.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

LOG DATA 2.

 

log data

166  * Plot with XAXIS and YAXIS;

167  proc template;

168  define style styles.LasVegas2;

169  parent = styles.default;

170  style GraphConfidence from GraphConfidence / color= CXE8D898;

171  style GraphLegendBackground / transparency=0;

172  style GraphValueText from GraphValueText / font=('Times New Roman', 12pt, Bold);

173  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

174  style GraphBorderLines from GraphBorderLines / LineThickness=0;

175  *style GraphWalls from GraphWalls / color= CXC0C0C0;

176  style GraphBackground / transparency=0;

177  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

178  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

179  ODs graphics on;

180  HEIGHT = 3in WIDTH = 4in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

181  ODS html style=LasVegas2;

182

183  ODS LISTING GPATH = 'c:\MyGraphs';

184

185  PROC SGPLOT DATA = bv ;

186  SERIES X = year Y = production /LINEATTRS=(thickness=3);

187  XAXIS LABEL = 'Year' values = (1979 TO 2027 BY 4) type=linear;

188  YAXIS LABEL = 'Production (tonnes)' values = (200000 TO 600000 BY 100000);

189  TITLE 'Marine total fish production';

190  RUN;

 

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.29 seconds

      cpu time            0.06 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot21.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

191  Ods graphics off;

192

193  PROC SGPLOT DATA=bv;

194  VLINE YEAR / RESPONSE=PRODUCTION;

195  XAXIS LABEL = 'Year' values = (1979 TO 2027 BY 4) type=linear;

196  XAXIS DISPLY=(NOLABEL);

           ------

           1

WARNING 1-322: Assuming the symbol DISPLAY was misspelled as DISPLY.

197  KEYLEGEND / POSITION=RIGHT   VALUEATTRS=(SIZE=9PT);

198  run;

 

NOTE: Since no format is assigned, the numeric category variable will use the default of BEST6.

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.31 seconds

      cpu time            0.04 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot23.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

LOG DATA 3.

 

log data

225  * Plot with XAXIS and YAXIS;

            ----

            388

            76

 

ERROR 388-185: Expecting an arithmetic operator.

 

ERROR 76-322: Syntax error, statement will be ignored.

 

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           30.70 seconds

      cpu time            0.48 seconds

 

 

 

226  proc template;

227  define style styles.LasVegas2;

228  parent = styles.default;

229  style GraphConfidence from GraphConfidence / color= CXE8D898;

230  style GraphLegendBackground / transparency=0;

231  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

232  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

233  style GraphBorderLines from GraphBorderLines / LineThickness=1;

234  *style GraphWalls from GraphWalls / color= CXC0C0C0;

235  style GraphBackground / transparency=1;

236  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

237  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

 

 

238  ODs graphics on;

239  HEIGHT = 4in WIDTH = 11in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

240  ODS html style=LasVegas2;

241

242  ODS LISTING GPATH = 'c:\MyGraphs';

243  data bv;

244          retain function 'text' x1space 'year' y1space'production'

245          rotate 45 anchor "right" width 30 textweight "bold";

246          length textcolor $20;

247          set sashelp.class;

248          label=year;

249  xc1=year;

250  y1=-5;

251  run;

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.00 seconds

 

LOG DATA 4.

 

log data

370  * Plot with XAXIS and YAXIS;

371  proc template;

372  define style styles.LasVegas2;

373  parent = styles.default;

374  style GraphConfidence from GraphConfidence / color= CXE8D898;

375  style GraphLegendBackground / transparency=0;

376  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

377  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

378  style GraphBorderLines from GraphBorderLines / LineThickness=1;

379  *style GraphWalls from GraphWalls / color= CXC0C0C0;

380  style GraphBackground / transparency=1;

381  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

382  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

383  ODs graphics on;

384  HEIGHT = 4in WIDTH = 11in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

385  ODS html style=LasVegas2;

386

387  ODS LISTING GPATH = 'c:\MyGraphs';

388

389  data bv;

390     retain function 'text' x1space 'datavalue' y1space 'datapercent'

391            rotate 45 anchor "right" width 30 textweight 'bold';

392     length textcolor $20;

393     set sashelp.class;

394     label=year;

395     xc1=year;

396     y1=-5;

397  run;

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

LOG DATA 5.

log

425  * Plot with XAXIS and YAXIS;

426  proc template;

427  define style styles.LasVegas2;

428  parent = styles.default;

429  style GraphConfidence from GraphConfidence / color= CXE8D898;

430  style GraphLegendBackground / transparency=0;

431  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

432  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

433  style GraphBorderLines from GraphBorderLines / LineThickness=1;

434  *style GraphWalls from GraphWalls / color= CXC0C0C0;

435  style GraphBackground / transparency=1;

436  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

437  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

438  ODs graphics on;

439  HEIGHT = 4in WIDTH = 11in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

440  ODS html style=LasVegas2;

441

442  ODS LISTING GPATH = 'c:\MyGraphs';

443

444  data bv;

445          retain function 'text' x1space 'year' y1space'production'

446          rotate 45 anchor "right" width 30 textweight "bold";

447          length textcolor $20;

448          set sashelp.class;

449          label=year;

450  xc1=year;

451  run;

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

LOG DATA 6.

log data

505  * Plot with XAXIS and YAXIS;

506  proc template;

507  define style styles.LasVegas2;

508  parent = styles.default;

509  style GraphConfidence from GraphConfidence / color= CXE8D898;

510  style GraphLegendBackground / transparency=0;

511  style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

512  style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

513  style GraphBorderLines from GraphBorderLines / LineThickness=1;

514  *style GraphWalls from GraphWalls / color= CXC0C0C0;

515  style GraphBackground / transparency=1;

516  end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

517  run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

518  ODs graphics on;

519  HEIGHT = 4in WIDTH = 11in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

520  ODS html style=LasVegas2;

521

522  ODS LISTING GPATH = 'c:\MyGraphs';

523

524  data bv;

525          retain function 'text' x1space 'year' y1space'production'

526          rotate 45 anchor "right" width 30 textweight "bold";

527          length textcolor $20;

528          set sashelp.class;

529          label=year;

530  run;

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

LOG DATA 7.

Log

37   * Plot with XAXIS and YAXIS;

38   proc template;

39   define style styles.LasVegas2;

40   parent = styles.default;

41   style GraphConfidence from GraphConfidence / color= CXE8D898;

42   style GraphLegendBackground / transparency=0;

43   style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

44   style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

45   style GraphBorderLines from GraphBorderLines / LineThickness=1;

46   *style GraphWalls from GraphWalls / color= CXC0C0C0;

47   style GraphBackground / transparency=1;

48   end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

49   run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

50   ODs graphics on;

51   HEIGHT = 4in WIDTH = 3in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

52   ODS html style=LasVegas2;

53

54   ODS LISTING GPATH = 'c:\MyGraphs';

55

56   data bv;

57           retain function 'text' x1space 'year' y1space'production'

58           rotate 45 anchor "right" width 30 textweight "bold";

59           length textcolor $20;

60           set sashelp.class;

61           label=year;

62   xc1=year;

63

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

 

64   PROC SGPLOT DATA = bv pad=(bottom=15%); ;

65   Series X = year Y = Production/ markers markerattrs=(symbol=circlefilled);

66   ;

67   series x=Year Y=Prediction/markers markerattrs=(symbol=circlefilled);

68   XAXIS LABEL = 'Year' values = (1979 TO 2026 BY 3) type=linear;

69   YAXIS LABEL = 'Production (tonne)' values = (200000 TO 600000 BY 100000);

70   TITLE 'Fig.1  total marine total fish production';

71   RUN;

 

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.68 seconds

      cpu time            0.20 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot1.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

72   Ods graphics off;

 

LOG DATA 8.

Log

73   * Plot with XAXIS and YAXIS;

74   proc template;

75   define style styles.LasVegas2;

76   parent = styles.default;

77   style GraphConfidence from GraphConfidence / color= CXE8D898;

78   style GraphLegendBackground / transparency=0;

79   style GraphValueText from GraphValueText / font=('Times New Roman', 9pt, Bold);

80   style GraphLabelText from GraphLabelText / font=('Times New Roman', 12pt, Bold);

81   style GraphBorderLines from GraphBorderLines / LineThickness=1;

82   *style GraphWalls from GraphWalls / color= CXC0C0C0;

83   style GraphBackground / transparency=1;

84   end;

NOTE: Overwriting existing template/link: Styles.LasVegas2

NOTE: STYLE 'Styles.LasVegas2' has been saved to: SASUSER.TEMPLAT

85   run;

NOTE: PROCEDURE TEMPLATE used (Total process time):

      real time           0.00 seconds

      cpu time            0.00 seconds

 

 

86   ODs graphics on;

87   HEIGHT = 4in WIDTH = 3in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

88   ODS html style=LasVegas2;

89

90   ODS LISTING GPATH = 'c:\MyGraphs';

91

92   data bv;

93      retain function 'text' x1space 'datavalue' y1space 'datapercent'

94             rotate 45 anchor "right" width 30 textweight 'bold';

95      length textcolor $20;

96      set sashelp.class;

97      label=year;

98

 

NOTE: Variable textcolor is uninitialized.

NOTE: Variable year is uninitialized.

ERROR: You cannot open WORK.BV.DATA for output access with member-level control because WORK.BV.DATA

is in use by you in resource environment ViewTable Window.

NOTE: The SAS System stopped processing this step because of errors.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

 

 

 

99   PROC SGPLOT DATA = bv pad=(bottom=15%); ;

100  Series X = year Y = Production/ markers markerattrs=(symbol=circlefilled);

101  ;

102  series x=Year Y=Prediction/markers markerattrs=(symbol=circlefilled);

103  XAXIS LABEL = 'Year' values = (1979 TO 2026 BY 3) type=linear;

104  YAXIS LABEL = 'Production (tonne)' values = (200000 TO 600000 BY 100000);

105  TITLE 'Fig.1  total marine total fish production';

106  RUN;

 

NOTE: PROCEDURE SGPLOT used (Total process time):

      real time           0.29 seconds

      cpu time            0.07 seconds

 

WARNING: GPATH or PATH is not a writable directory. It will be ignored.

NOTE: Listing image output written to SGPlot3.png.

NOTE: There were 50 observations read from the data set WORK.BV.

 

107  Ods graphics off;

BrunoMueller
SAS Super FREQ

Hi

 

There are a lot off error messages, too many to correct them all here, but you just have to work your way down from the top and check each error message, so for instance

 

202  ODs graphics on;

203  HEIGHT = 4in WIDTH = 3in;

     ------

     180

 

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Gives a clear indication that height is not a vlaid statement in this context, looking at the syntax for ODS GRAPHICS will show that it should look like this:

 

ODs graphics on /   HEIGHT = 4in WIDTH = 3in;

If you really need the thick values rotated the way you want, I suggest to use the VBARPARM and TEXT plot statements. It is less effort as compared to annotate, but then you have less control over the appearance.

 

/* create table for bar chart */
proc sql;
  create table cars1 as
    select
      type
      , mean(invoice) as invoice
    from
      sashelp.cars
    group by
      1
  ;
quit;

/*
 * create table for text plot
 * variable names must be named differently to the first table * 
 */
proc sql;
  create table cars2 as
    select distinct
      type as type2
      , -1000 as value2
    from
      sashelp.cars
  ;
quit;

/* combine the two data sets into one */
data carsplot;
  set cars1 cars2;
run;

/* make use of the vbarparm and text plot statements */
proc sgplot data=carsplot noborder noautolegend;
  vbarparm category=type response=invoice;
  text x=type2 y=value2 text=type2 / 
    rotate=45
    position=bottomleft 
    textattrs=(SIZE=8pt)    
  ;
  xaxis display=none;
run;

However I would suggest to go with what is currently available.

 

Bruno

Jay54
Meteorite | Level 14

Hey Bruno,  This is a clever idea to use TEXT plot to draw rotated values.  You could turn off the y-axis line, and only keep grids and values.   That said, it is not clear to me why rotated values are so important in this case.  Split tick values (now default) are much easier to read.  If the tick values are long, a HBAR may be preferable.

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
  • 11 replies
  • 4162 views
  • 7 likes
  • 5 in conversation