Here is a tiny set of data which can reproduce this issue:
DATA ;
input sat examFreqData;
Datalines;
1 3
2 3
3 2
4 7
5 8
6 7
;
PROC PRINT DATA=examFreqData;
title 'Exam!';
RUN;
PROC PLOT DATA=examFreqData;
PLOT count*exam / haxis=0 to 7 by 1 vaxis=0 to 10 by 1;
RUN;
proc gplot DATA=examFreqData;
title 'Exam Frequency Polygon';
symbol1 v=none i=join;
plot count*exam;
RUN;
I get this error from PROC PLOT:
ERROR: All values missing or out of range for COUNT*exam. Check VAXIS= and HAXIS= specifications.
Since the data is from 1 to 6, even if we consider adding one to each extreme, 0 to 7 ought to cover it.
I tried the PROC PLOT because the PROC GPLOT kept producing an ugly graph with three "1"s at the left edge.
For goodness sake! It is fine if the graph does not go all the way from left to right on the screen, but don't repeat
data values. I added the PROC PRINT to verify that my data set looked the way I expected it to.
What is going on? I know it is a small data set, but I expect SAS can handle it.
Thanks!
1) Posted code needs a QUIT; at the end of the proc. Gplot supports run group processing and so needs quit; to tell the procedure the end of the submitted code.
2) The resulting plot I get from you example data does not have 3 ones so your example data obviously does not have your full data behavior.
3) You will have to provide a better description of what you mean by "looks terrible". You can attach a PNG file of the output you generated. I have attached the result I got from your data.
Your input data set does not have a variable named count or exam assuming the shown data set was supposed to be named examfreqdata.
You have variables SAT and examFreqData.
may be if you used:
DATA examFreqData;
input exam count;
Datalines;
1 3
2 3
3 2
4 7
5 8
6 7
;
Right! Sorry! Let me correct that. I originally created this data with a recode and a PROC FREQ.
Please use the corrected data set as specified by ballardw:
DATA examFreqData;
input exam count;
Datalines;
1 3
2 3
3 2
4 7
5 8
6 7
;
You will see that the PLOT errors out and the GPLOT has THREE 1's in it and looks terrible.
We are running SAS 9.4 on Windows
1) Posted code needs a QUIT; at the end of the proc. Gplot supports run group processing and so needs quit; to tell the procedure the end of the submitted code.
2) The resulting plot I get from you example data does not have 3 ones so your example data obviously does not have your full data behavior.
3) You will have to provide a better description of what you mean by "looks terrible". You can attach a PNG file of the output you generated. I have attached the result I got from your data.
Heck, I just quit and restarted SAS and now it plots perfectly just like you said. I guess I have a severe ignorance about when to restart SAS and what it is holding in memory. Something was cached from previous runs which was interfering with the correct plotting of data sets. The PROC PRINT looked good, but the PROC PLOT and GPLOT looked terrible. Now they look exactly as they should and I thank ballardw for the expertise and time. I apologize for not having tried closing SAS in between runs.
Since you didn't actually show any HAXIS type options it may well be that what ever you experimented with was causing an issue.
Since you didn't show an example with the multiple "1" values I can say the likeliest way I know to do that is usually the result of a combination of AXIS options and a format. Possibly an ORDER of 0 to 3 by .3 but not a Value clause and a format with no decimals for the variable.
data junk; do x= 0 to 5 by .2; y= 1 + .2*x; output; end; format y f1.; run; axis1 order = ( 0 to 5 by .3); proc gplot data=junk; plot y*x /vaxis=axis1; run; quit;
I did not do any of that (axis or format). I originally was just using GPLOT, with no extra options and then PLOT. I added the axis statements to try to make SAS behave, but it did not help.
Something was stuck in SAS buffer that was not being wiped between runs, and as soon as I restarted SAS I could not replicate problem. I should have grabbed an image while it was still malfunctioning but when I added the QUIT; statement it shut down my SAS session. Sorry, I did not see that coming, but now it is obvious to me.
If I had to speculate, I would say that one of my earlier attempts to create the data set from PROC FREQ had an error in it, and even though the PROC PRINT showed the correct data set, when it came time to PLOT, the data was accessed from a cached version in the local WORK data set instead of from the one that I had just created. Ending the session cleared out the WORK buffer.
A number of graphics options persist from session to session, which started maybe in SAS version 9(?) where prior they didn't.
One statement you will want to learn if you continue to use the device based graphics procedures (gplot, gchart, gmap) is:
goptions reset=all;
Which will reset all the options to the installed defaults.
Note the reset will also take some arguements to affect just a subset of options, read the documentation, but when things start going very badly then reset everything.
If you were not making Axis statements I suspect that you may have been running a data step that was duplicating data when you only really needed ot work with the GPLOT code. One place to look at datasteps very carefully is using the structure:
Data SomeDataset;
Set SomeDataset;
<code>;
run;
Depending on what is actually in that <code> section rerunning the data step multiple times can yield very bad data.
Here's an exampe;
Data example;
set example;
if 1< age <14 then age=age-1;
run;
If you actually have an age variable with values that start under 14 then rerunning that datastep multiple times will end up with a bunch of age vales of 1.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.