Hey all,
I tried to format the values of the xaxis from numeric to scientific notation, because I thought that might be an explanation why the tick intervals of 5000 don't work. It would be sufficient to have just minor ticks without notation.
Every format I could find here ( https://documentation.sas.com/?docsetId=grstatproc&docsetVersion=9.4&docsetTarget=n0kdscfhkob956n196...) is without explanation and not working also.
Gross E8 worked previously with proc boxplot, but not with sgplot.
Where can I find explanation for the available formats and how can I change my xaxis values properly?
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73 proc sgplot data=income;
74 histogram dollar;
75 yaxis values=(0 to 62 by 5) grid;
76 xaxis values=(0 to 105E3 by 5E3) valuesformat=best;
77 run;
ERROR 772-580: Syntaxfehler: Konstanter oder dynamischer Wert erwartet.
WARNING: Object will not be saved.
NOTE: Verwendet wurde: PROZEDUR SGPLOT - (Gesamtverarbeitungszeit):
real time 0.00 seconds
cpu time 0.02 seconds
NOTE: The SAS System stopped processing this step because of errors.
78
79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;Thank you so much!
Use e. format and option minor, and specify the values for major ticks only :
data test;
call streaminit(67678568);
do i = 1 to 200;
dollar = 1e5 * rand("Beta", 4, 4);
output;
end;
run;
proc sgplot data=test;
histogram dollar;
xaxis values=(0 to 105E3 by 1E4) minor minorcount=1 valuesformat=e8. ;
run;
proc sgplot data=income; histogram dollar; format dollar best12.; yaxis values=(0 to 62 by 5) grid; xaxis values=(0 to 105E3 by 5E3); run;
I ran that without any changes in the xaxis.
Furthermore: my goal is it to have minor ticks on the xaxis, how do I do that?
Sorry, I'm completely new to SAS, never did anything like this before.
I can't find a list whatsoever for SAS formats and what they do and how they look like, so I don't know how they are supposed to be.
I tried this now:
proc sgplot data=income; histogram dollar; format dollar 12.; yaxis values=(0 to 62 by 5) grid; xaxis values=(0 to 105E3 by 5E3); run;
but no changes on the xaxis.
You should probably bookmark the documentation page then:
From there you can usually find everything you need, in this case click on formats and then search for scientific notation. Note the document type field as well - you likely want "Document: SAS Formats and Informats: Reference" not DS2.
|
Ew.
Writes numeric values in scientific notation.
Product: Base SAS
Document: SAS DS2 Language Reference
|
proc sgplot data=income;
histogram dollar;
format dollar 12.;
yaxis values=(0 to 62 by 5) grid;
xaxis values=(0 to 105E3 by 5E3);
format dollar e8.;
run;
I tried to run it with ew. but nothing changed.
@Lacona wrote:
Sorry, I'm completely new to SAS, never did anything like this before.
I can't find a list whatsoever for SAS formats and what they do and how they look like, so I don't know how they are supposed to be.
I tried this now:proc sgplot data=income; histogram dollar; format dollar 12.; yaxis values=(0 to 62 by 5) grid; xaxis values=(0 to 105E3 by 5E3); run;but no changes on the xaxis.
I don't think the format command does anything in PROC SGPLOT, although it does work in most other procedures. In PROC SGPLOT you need the VALUESFORMAT= option of the XAXIS and/or YAXIS statement.
List of every known format in SAS 9.4:
@Lacona wrote:
Hey all,
I tried to format the values of the xaxis from numeric to scientific notation, because I thought that might be an explanation why the tick intervals of 5000 don't work. It would be sufficient to have just minor ticks without notation.
Every format I could find here ( https://documentation.sas.com/?docsetId=grstatproc&docsetVersion=9.4&docsetTarget=n0kdscfhkob956n196...) is without explanation and not working also.Gross E8 worked previously with proc boxplot, but not with sgplot.
Where can I find explanation for the available formats and how can I change my xaxis values properly?
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 proc sgplot data=income; 74 histogram dollar; 75 yaxis values=(0 to 62 by 5) grid; 76 xaxis values=(0 to 105E3 by 5E3) valuesformat=best; 77 run; ERROR 772-580: Syntaxfehler: Konstanter oder dynamischer Wert erwartet. WARNING: Object will not be saved. NOTE: Verwendet wurde: PROZEDUR SGPLOT - (Gesamtverarbeitungszeit): real time 0.00 seconds cpu time 0.02 seconds NOTE: The SAS System stopped processing this step because of errors. 78 79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;Thank you so much!
Note the dot after the word best
xaxis values=(0 to 105E3 by 5E3) valuesformat=best.;
Although as others have said, maybe you don't want the BEST. format in this case.
Use e. format and option minor, and specify the values for major ticks only :
data test;
call streaminit(67678568);
do i = 1 to 200;
dollar = 1e5 * rand("Beta", 4, 4);
output;
end;
run;
proc sgplot data=test;
histogram dollar;
xaxis values=(0 to 105E3 by 1E4) minor minorcount=1 valuesformat=e8. ;
run;
To confirm, you are trying to add the scientific notation format to the xaxis in your histogram?
Try this. I am using the SASHELP.CARS table that you probably have available:
/*Copy SASHELP.CARS, copy MSRP to Price. Price has no format*/
data cars;
set sashelp.cars;
keep Price;
Price=MSRP;
run;
/*Default histogram. No format or new xaxis values*/
proc sgplot data=cars;
histogram price;
run;
/*Add a format and new xaxis values range*/
proc sgplot data=cars;
histogram price;
xaxis values=(0 to 200000 by 25000);
format price e8.;
run;
Yesss!!! It worked! Thank you all!
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.